How to make a test fail if it takes too long?


I'm using MSTest which is the default unit testing platform in visual studio and I have this test here:

    public void Board_nao_destroi_unidades_flutuantes()
        var ctor = new Construction();

He's waiting for an exception to pass but instead he goes into a loop and delays the other 92 tests. What is the way of saying that if my test takes a certain amount of milliseconds it will fail?

asked by anonymous 12.04.2014 / 15:34

1 answer


As the MSDN Web site ( link ), just use the Timeout attribute.

[TestMethod(), Timeout(80)]
public void MyTestMethod()
12.04.2014 / 15:37