Timeout attribute does not call test cleanup method
See original GitHub issueSteps to reproduce
[TestClass]
public class TestCleanup
{
[TestInitialize()]
public void MyTestInitialize()
{
Console.WriteLine("Calling initialize");
}
// Use TestCleanup to run code after each test has run
[TestCleanup()]
public void MyTestCleanup()
{
MessageBox.Show("Cleanup");
Console.WriteLine( ng cleanup");
}
[Timeout(5000)]
[TestMethod]
public void TestMethod1()
{
Console.WriteLine("Sleeping for 10 seconds");
System.Threading.Thread.Sleep(10000);
Console.WriteLine("Waking up");
}
}
Expected behavior
It is essential all tests execute their TestCleanup code, as this code may have important steps to recover from an error such as a time out.
Actual behavior
The result of executing this code is the test times out but the message box is not displayed and the Calling cleanup message is not written to the console.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:34
- Comments:18 (8 by maintainers)
Top Results From Across the Web
Timeout attribute for Mstest does not call test cleanup method
I consider this a bug. It is essential all tests execute their TestCleanup code, as this code may have important steps to recover...
Read more >MStest aborts test cleanup - visual studio 2013
The issue is that when a test is aborted with timeout, the test cleanup is given a very short amount of time to...
Read more >Timeout
The TimeoutAttribute is used to specify a timeout value in milliseconds for a test case. If the test case runs longer than the...
Read more >Most Complete NUnit Unit Testing Framework Cheat Sheet
The TimeoutAttribute is used to specify a timeout value in milliseconds for a test case. If the test case runs longer than the...
Read more >Writing tests for Twisted code using Trial
The way to do this in Trial is to set the .timeout attribute on your unit test method. Set the attribute to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can’t fathom how this is remotely an enhancement rather than a serious bug that should be fixed ASAP 😕. Makes using
Timeout
absolutely useless and dangerous.In more complex scenarios like E2E UI tests where more than one failure may need to be collected and analyzed per test, this could be called a bug rather than enhancement.