nunit.analyzers
nunit.analyzers copied to clipboard
Do Not Allow Any Assertions to be Used in TearDown
Description
Based on discussion from here: https://github.com/nunit/docs/issues/149
If a method is marked with [TearDown], no assertion calls from the Assert class should be allowed.
Example
[TearDown]
public void TearDown()
{
Assert.That(true, Is.True); // This line would be flagged.
}
Analyzer Message
"No methods from the Assert class may be used in a [TearDown] method"
Default Severity Level
Error
Code Fixes
none
@JasonBock These seem like useful issues and they have crossreferenced activity. Would it bother you if we kept them open longer?
I was thinking the same. If you prefer to have a "clean slate" wrt. open NUnit issues you have created, then I can also create a new issue a replacement for this (and similar for the other two issues)
You can re-open them if you like.
Should the same analyser warn against use of Assume?
Should the same analyser warn against use of Assume?
Yes, I would say so.