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
When using LifeCycle.InstancePerTestCase, the OneTimeSetUp and OneTimeTearDown methods must be static, and each are only called once. This is required so that the setup or teardown methods do not access instance fields or properties that are reset for every test.
I would like to see the analyzer detect the following:
I agree the first part is a good rule to have.
The second though is technically valid, although unnecessary.
I have even seen fixtures were all tests are static. You can even have static fixtures.
As per the
NUnit
documentationI would like to see the analyzer detect the following:
[FixtureLifeCycleAttribute(LifeCycle.InstancePerTestCase)]
&non static [OneTimeSetUp]/[OneTimeTearDown]
- Error:[FixtureLifeCycleAttribute(LifeCycle.SingleInstance)]
&static [OneTimeSetUp]/[OneTimeTearDown]
It would also be great if the analyzer is aware of assembly level attributes, they may not be defined on the class.
The text was updated successfully, but these errors were encountered: