I've got a situation where I'm using a unit test to execute an external tool which performs a test. I can determine from the tool's exit code whether the test passed, failed or timed out.
Is there some way that I can fail the unit test which will set the test outcome to timeout instead of failed?
I've tried throwing a TimeoutException, but this has the same result as using an Assert.
Edit: We're linking the unit tests up with test cases in TFS. In Microsoft Test Center a test in a test run can have many states. One of which is the timeout state. I'm trying to fail my test so that it correctly shows up in this state and does not get bunched up with the failed test cases.
You can set timeout limit per test, using addition of Timeout(millisecond) in Test attribute...
[TestMethod, Timeout(2000)]
Test will fail if execution takes longer than 2 seconds.
Thanks Marko
It is not really "programmatically" but you could:
Use Test Settings in Microsoft Test Center if you run your tests from Microsoft Test Center or using tcm.exe (see Run Tests from the Command Line Using Tcm)
Your test just should wait if it recognized that the external tool returns with the time out exit code (this would be the "programmatic" part.)
So the testing framework will set the test outcome to "Timeout" for you.
Especially if your tests are automated it would be a suitable solution, I suppose.
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