Is it possible to have a deterministic ClassCleanup when testing MSTest / VS modules?

i.e. so that the method decorated with the ClassCleanup attribute is executed immediately after all the tests in the test class? (e.g. TestFixtureTearDown on NUnit). Any workarounds?

An alternative to embedding this heavy setup / break in TestInitialize and TestCleanup will simply increase the test execution time.

I compared them over the past week. (This is what I found NUnit vs MSTest . I don't have much time to fly to MSTest, so if I make a mistake, please feel free to send corrections in the form of comments ..)

This particular element is a show show, as far as I know. Read the first section of your blog post if you want more information.

+5
source share
2 answers

ClassInitialize and ClassCleanup are called right after loading your class and right before your class is unloaded.

This is true, but classes are unloaded in bulk after all tests are completed.

eg.

ClassInitialize1
TestInitialize1
TestMethod11
TestCleanup1
TestInitialize1
TestMethod12
TestCleanup1
ClassInitialize2
TestInitialize2
TestMethod21
TestCleanup2
TestInitialize2
TestMethod22
TestCleanup2
TestInitialize2
TestMethod23
TestCleanup2
ClassCleanup1
ClassCleanup2

+1

MSDN ClassCleanup :

ClassInitialize ClassCleanup , , .

, , .

0

All Articles