C#测试中的超时 [英] Timeout in c# tests
本文介绍了C#测试中的超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
任何人都可以知道测试超时后是否总是执行finally.
Can anyone tell if finally is always executed after a test times out or not.
[Timeout(1000)][TestMethod]
public void test()
{
try
{
System.Threading.Thread.Sleep(2000);
}
finally
{
//do something
}
}
推荐答案
如果可能,请使用TestCleanUp方法,以便在测试超时后进行测试.
If possible, use the TestCleanUp method in order to do work after the test if it is subject to timeouts.
这篇关于C#测试中的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文