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
We have the following structure in some of our test projects:
[TestClass]
public abstract class TestBase
{
public TestContext TestContext { get; set; }
[TestInitialize]
public void RunTestSetup()
{
...
}
[ClassCleanup]
public static void ClassCleanup()
{
...
}
}
[TestClass]
public sealed class SomeTest : TestBase
{
...
}
After upgrading to 3.3.1 we started getting the error:
error MSTEST0016: Test class 'TestBase' should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialization]' and/or '[AssemblyCleanup]'
Should MSTEST0016 be checking for this pattern and not trigger the warning/error, or is there a better approach?
The text was updated successfully, but these errors were encountered:
As usual thank you for testing our analyzers and for your continuous feedback to improve MSTest :)
Assuming you don't have test methods in TestBase then you don't need the [TestClass] attribute on the base class.
Side note not related to MSTEST0016 but [ClassCleanup] is working in a counter intuitive way (I plan to fix this in v4 as it implies breaking changes). By default it is equivalent to [AssemblyCleanup] and runs after all tests have been executed and not all tests of current class or children classes. To change this you will need to pass ClassCleanupBehavior.EndOfClass
Just to be sure. Does it mean that when you process classes marked with TestClassAttribute you include the whole hierarchy? Will DeploymentItemAttribute on TestBase be processed as well?
We have the following structure in some of our test projects:
After upgrading to 3.3.1 we started getting the error:
error MSTEST0016: Test class 'TestBase' should have at least one test method or be 'static' with method(s) marked by '[AssemblyInitialization]' and/or '[AssemblyCleanup]'
Should MSTEST0016 be checking for this pattern and not trigger the warning/error, or is there a better approach?
The text was updated successfully, but these errors were encountered: