-
Notifications
You must be signed in to change notification settings - Fork 290
Closed
Description
Description
When the ClassCleanup attribute is declared on a base type with ClassCleanupBehavior.EndOfClass, it still triggered at end of assembly.
Steps to reproduce
Run this code:
[TestClass]
public class TestClassBase
{
[ClassInitialize(InheritanceBehavior.BeforeEachDerivedClass)]
public static void BeforeClsBase(TestContext testContext)
{
Log.Message("ClassInitialize - TestClassBase");
}
[ClassCleanup(InheritanceBehavior.BeforeEachDerivedClass, ClassCleanupBehavior.EndOfClass)]
public static void AfterClsBase()
{
Log.Message("ClassCleanup - TestClassBase");
}
}
[TestClass]
public class TestClassDerivedA : TestClassBase
{
[TestMethod]
public void TestMethod()
{
Log.Message("Test Method A");
}
}
[TestClass]
public class TestClassDerivedB : TestClassBase
{
[TestMethod]
public void TestMethod()
{
Log.Message("Test Method B");
}
}
Expected behavior
ClassCleanup is triggered at the end of class, according to 'ClassCleanupBehavior.EndOfClass'
Actual behavior
Log output:
ClassInitialize - TestClassBase
Test Method A
ClassInitialize - TestClassBase
Test Method B
ClassCleanup - TestClassBase
ClassCleanup - TestClassBase
Environment
VS 2019
MSTest.TestAdapter: 2.2.10
MSTest.TestFramework: 2.2.10
nixdagbibts