Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When MSTest fails in TestInitialize, why doesn't TestCleanup get executed?

I have a base class that has a TestInitialize and a TestCleanup in it. I then have other test classes which inherit from this class. The TestCleanup is supposed to perform certain actions when a test from the derived class fails.

The TestCleanup gets executed when the test fails in the actual test. However, when the test fails in the TestInitialize, the TestCleanup doesn't even get executed. Why does this happen and is there a way to get the TestCleanup to get called anyway?

I don't think that the fact that the TestInitialize and TestCleanup are in a base class is at all causing this issue, I just wanted to give more information just in case it was.

like image 944
jgerstle Avatar asked Jan 12 '23 21:01

jgerstle


1 Answers

This is a known issue. It looks like it has been reported to Microsoft connect.

http://connect.microsoft.com/VisualStudio/feedback/details/694337/testcleanup-method-does-not-run-when-it-should

like image 145
dixus Avatar answered Jan 20 '23 04:01

dixus