3
A
回答
3
尝试添加下面一行在你的main()
测试
void main(List<String> args) {
useHtmlEnhancedConfiguration(); // (or some other configuration setting)
unittestConfiguration.timeout = new Duration(seconds: 3); // <<== add this line
test(() {
// do some tests
});
}
你可以很容易地安装使用setUp()
和tearDown()
和Timer
library x;
import 'dart:async';
import 'package:unittest/unittest.dart';
void main(List<String> args) {
group("some group",() {
Timer timeout;
setUp(() {
// fail the test after Duration
timeout = new Timer(new Duration(seconds: 1),() => fail("timed out"));
});
tearDown(() {
// if the test already ended, cancel the timeout
timeout.cancel();
});
test("some very slow test",() {
var callback = expectAsync0((){});
new Timer(new Duration(milliseconds: 1500),() {
expect(true, equals(true));
callback();
});
});
test("another very slow test",() {
var callback = expectAsync0((){});
new Timer(new Duration(milliseconds: 1500),() {
expect(true, equals(true));
callback();
});
});
test("a fast test",() {
var callback = expectAsync0((){});
new Timer(new Duration(milliseconds: 500),() {
expect(true, equals(true));
callback();
});
});
});
}
这个时间保护失灵,整个组,但组可以嵌套,因此您可以完全控制应该监视哪些测试超时。
相关问题
- 1. 飞镖单元测试时,我如何始终如一地设置环境?
- 2. 飞镖异步单元测试
- 3. 飞镖单元测试 - 始终通过
- 4. 单元测试超时
- 5. 单元测试超时
- 6. 如何在单元测试中访问飞镖班
- 7. 时间戳测试单元测试
- 8. Apache HttpClient中的单元测试超时
- 9. 单元测试时间差
- 10. 如何为每个硒测试用例设置超时时间?
- 11. python3如何设置在单元测试中通过的测试
- 12. 使用新的测试库设置飞镖单元测试的最佳方式是什么?
- 13. 在mstest中设置测试套件的超时时间
- 14. 在飞镖中测试性能
- 15. 如何设置测试状态中测试单元成功
- 16. 如何覆盖单元测试目的的时间戳字段?单元测试设置的
- 17. 飞镖单元测试应该失败的例外
- 18. 单元测试,黑盒测试时需要多长时间?
- 19. 支持每个单元测试类的超时时间?
- 20. 飞镖单元测试:orderedEquals与Batman蝙蝠侠
- 21. 将超时设置为Qt测试
- 22. Qt单元测试设置
- 23. 如何设置HttpContext.Current.User.Identity.Name单元测试
- 24. 如何在ruby中单元测试超时异常的方法
- 25. 如何在pytest中设置默认的每次测试超时?
- 26. Python单元测试。如何在测试用例之间添加睡眠时间?
- 27. 如何在soapui中为一个测试步骤设置超时时间?
- 28. 我应该如何测试飞镖中的未来?
- 29. eunit测试超时
- 30. 测试iFrame的location.href是否在jasmine单元测试中设置
这是所有测试的全球设置,对不对?目前我们无法设置指定测试的超时时间。 – Freewind
@Freewind我添加了每个测试超时的示例。到目前为止,不知道是否有情况下没有。刚发明它;-) –