简体   繁体   English

支持每个单元测试类超时吗?

[英]Timeout per unit-test class supported?

In NUnit I can add a [Timeout(5000)] attribute at the TestFixture (test class) level to specify an upper limit for each test method in that class. 在NUnit中,我可以TestFixture (测试类)级别添加[Timeout(5000)]属性以指定该类每个测试方法的上限。

In xUnit, I know I can do something similar, but at the test method level: [Fact(Timeout=5000)] . 在xUnit中,我知道我可以做类似的事情,但是在测试方法级别: [Fact(Timeout=5000)]

My question is: can I apply a timeout at the test class level with xUnit ? 我的问题是:我可以使用xUnit在测试类级别应用超时吗?

This may not be the answer you would like to see but for what it is worth ... 这可能不是您想要看到的答案,但值得一试...

The recommendation here is to create your own replacement for FactAttribute which derives from FactAttribute and sets up any default values you want (like timeout). 这里的建议是创建自己的FactAttribute替代品,该替代品源自FactAttribute并设置所需的任何默认值(例如超时)。

Reference: http://xunit.codeplex.com/workitem/9727 参考: http : //xunit.codeplex.com/workitem/9727

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM