i.e. to have the method decorated with ClassCleanup attribute executed once immediately after all tests in a test class ? (like TestFixtureTearDown in NUnit). Any workarounds ?
The alternative of embedding this heavy setup/teardown in TestInitialize and TestCleanup would just drive up the test execution times.
I was comparing the two over the past week. (Here's what I found NUnit vs MSTest . Don't have a lot of flying time in MSTest, so if I've made a mistake, please feel free to post corrections as comments..)
This particular item is a showstopper as far as I am concerned. Read the first section of the blog post in case you'd like more details.
ClassInitialize and ClassCleanup are called right after your class is loaded and right before your class is unloaded.
It's true, but classes are bulk-unloaded after all tests finished running.
E.g.
ClassInitialize1
TestInitialize1
TestMethod11
TestCleanup1
TestInitialize1
TestMethod12
TestCleanup1
ClassInitialize2
TestInitialize2
TestMethod21
TestCleanup2
TestInitialize2
TestMethod22
TestCleanup2
TestInitialize2
TestMethod23
TestCleanup2
ClassCleanup1
ClassCleanup2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With