You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code raises NUnit1032 on the declaration of Enumerator.
using FluentAssertions;
using NUnit.Framework;
public static class ExampleTests
{
private static readonly IEnumerator<string> Enumerator = new List<string>().GetEnumerator();
[OneTimeTearDown]
public static void TearDown()
{
Enumerator.Dispose();
}
[Test]
public static void StubTest()
{
true.Should().BeTrue();
}
}
I suggest that either NUnit1032 should not be raised at all as Enumerator is static, or it should be cleared by the existence of the TearDown function.
It seems to be the static keyword causing issues here. Making the class and the TearDown function non-static removes the NUnit1032 error.
edit: typos
The text was updated successfully, but these errors were encountered:
I'm afraid I'm just maintaining some code rather than being the original author, so I can only speculate as to the reason for using static. I'm considering just making the tests non-static as a workaround for this issue in the short-term.
I suspect the reason for using static is because some static code analysers push for you to make things static as a default unless there is a reason it needs to be non-static. I think pragmatically, it's not a hill anyone would choose to die on either way :)
Discovered on NUnit.Analysers v3.8.0.
The following code raises NUnit1032 on the declaration of Enumerator.
I suggest that either NUnit1032 should not be raised at all as Enumerator is static, or it should be cleared by the existence of the TearDown function.
It seems to be the
static
keyword causing issues here. Making the class and the TearDown function non-static removes the NUnit1032 error.edit: typos
The text was updated successfully, but these errors were encountered: