nunit.analyzers
nunit.analyzers copied to clipboard
Check if test does not have assert(s).
For catching mistakes like:
[Test]
public void SomeTest()
{
// Assert.AreEqual(...);
}
Perhaps very common.
Don't warn if [Ignore]
or [Explicit]
Not sure is possible. Asserts might be present somewhere in user code, not nessesary directly in test method. Besides, external assertion libs (e.g. FluentAssertions) would be a pain as well, I suppose
I use Shouldly a lot these days, so this would be every test method for me. Maybe an opt-in diagnostic would make sense?
The usefulness is perhaps negative, not a common bug. We had a guy who had a habit of commenting out the body of test methods or asserts that were troublesome. 🙂
Empty test method bodies sound like a good thing to warn for. What do you think?
Yes it is a trivial analyzer with nonzero value.