Repository navigation
Enable XUnit Analyzers - #38676
Enable XUnit Analyzers#38676
Conversation
6222de7 to
1bea254
Compare
|
Most of these changes don't seem particularly valuable. Do we really need all of the rules enabled? The most important thing is ensuring that tests that should be run are run, which means all theories should have member/inline/etc. datas, and public parameterless void/Task methods should either be made private or be made [Fact]s/[Theory]s. |
|
It's fairly easy to opt-out of analyzer rules. This can be applied per assembly or for multiple assemblies / repo wide.
That's definitely something to watch out for but IMO not the only reason to enable the xunit analyzers. I can come up with a list of rules that might not offer much value (https://xunit.net/xunit.analyzers/rules/) |
Which others do you view as critically important? I would rather we enable the "this is a test that should run but isn't" rules for all of corefx (I expect there are only a few violations, which we should be able to fix quickly), rather than delay rolling it out project by project, gated on addressing lots of minor quibbles. |
|
💡 xUnit1004 (Test methods should not be skipped) is handy to keep at severity Hidden. Hidden severity eliminates the message from the error list but keeps the ability to use the diagnostic's code fix to remove the Skip attribute. Setting it to None disables the diagnostic entirely so the code fix will not be available to use as a refactoring. |
There's a significant difference between: I do think (a) is pretty darn important. It means things we expected to be tested aren't, and until we know what they are, we don't know whether they're critical or not. Out of your list, to me that means we should just blanket enable:
Many of the others are about catching at compile time what will otherwise be caught at runtime, e.g. xUnit1001 catches cases where a [Fact] has parameters, and that will today cause runtime failures. Would it be nice to catch at compile time instead? Yeah, it'd be nice. But it's not worth holding up the above for it. (That said, we should have 0 violations of these, exactly because they're checked at runtime.) I would like to do this rather than doing it piecemeal, as this PR starts to do. If you don't want to do it or don't have time to, I'll do it. I'd be fine then if we wanted to incrementally enable the remainder of the rules. |
1bea254 to
88a85ac
Compare
|
@stephentoub as discussed I updated the PR and addressed the most important rules across the repo. I expect test failures as I enabled a lot of tests. |
88a85ac to
742714d
Compare
|
(Please make sure to squash this all when merging.) |
d47f211 to
196c2ff
Compare
196c2ff to
283264e
Compare
|
This is ready to be squashed into master. I opened https://github.com/dotnet/corefx/issues/39233 for |
|
Thanks, @ViktorHofer. |
|
No need to thank me, we all care about test quality. I'm glad that we now have static analysis to capture wrong annotations. |
* Enable XUnit Analyzers Commit migrated from dotnet/corefx@b8a7f34
* Enable XUnit Analyzers Commit migrated from dotnet/corefx@b8a7f34
Contributes to https://github.com/dotnet/corefx/issues/38677
I disabled the analyzer on five projects which need a bit more work:
... and two private.xml ones