Skip to content

Conversation

@Youssef1313
Copy link
Member

The suggestion in #522 which was implemented in #3334 doesn't sound reasonable to me and adds unnecessary complications.

The timeout applies to the whole test method including initialize and cleanup. If it timed out, we shouldn't attempt to run cleanup. Today, we will run the class cleanup and wait for it. If it took forever, we will be waiting and will have exceeded the test timeout. Try to run the following today:

[TestClass]
public class TestCleanup
{
    [TestInitialize]
    public void MyTestInitialize()
    {
        Console.WriteLine("Calling initialize");
    }

    [TestCleanup]
    public void MyTestCleanup()
    {
        Thread.Sleep(1000000);
    }

    [Timeout(5000)]
    [TestMethod]
    public void TestMethod1()
    {
        Console.WriteLine("Sleeping for 10 seconds");
        System.Threading.Thread.Sleep(10000);
        Console.WriteLine("Waking up");
    }

}

I would expect the test to timeout after ~5 seconds. But because we run test cleanup, we are waiting on the large sleep in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants