I have hierarchy of functional tests like this
[TestClass]
class BaseClass
{
// specific methods and members relevant to all functional tests are here
// ie how to work with db
}
[TestClass]
class Module1:BaseClass
{
[ClassInitialize]
public static void Module1TestsInit(TestContext context)
{
//create some db data here, which is needed only for Module1
}
[ClassCleanup]
public static void Module1TestsCleanup()
{
//delete Module1 db data
}
}
[TestClass]
class Module2:BaseClass
{
[ClassInitialize]
public static void Module2TestsInit(TestContext context)
{
//create some db data here, which is needed only for Module2
}
[ClassCleanup]
public static void Module2TestsCleanup()
{
//delete Module2 db data
}
}
When the tests are executed I am expecting that [ClassCleanup]
will run when all methods from Module1
are completed and then again when Module2
tests are finished. I have many classes like Module1 with the same base class.
However, all ClassCleanup methods do run only when ALL tests from all modules completes. That is not convenient since I have some conflicting data in the different modules and want to clean up each class results when this class tests finished.
Any thoughts?