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. 如何设置单元测试在TFS Build Server中运行的超时时间
- 5. 单元测试超时
- 6. 单元测试超时
- 7. 如何在单元测试中访问飞镖班
- 8. 时间戳测试单元测试
- 9. Apache HttpClient中的单元测试超时
- 10. 单元测试时间差
- 11. 如何为每个硒测试用例设置超时时间?
- 12. python3如何设置在单元测试中通过的测试
- 13. 使用新的测试库设置飞镖单元测试的最佳方式是什么?
- 14. mstest中单元测试的默认超时时间是多少?
- 15. 在mstest中设置测试套件的超时时间
- 16. 在飞镖中测试性能
- 17. 如何设置测试状态中测试单元成功
- 18. 如何覆盖单元测试目的的时间戳字段?单元测试设置的
- 19. 飞镖单元测试应该失败的例外
- 20. 飞镖单元测试的pgsql查询错误
- 21. 单元测试,黑盒测试时需要多长时间?
- 22. 支持每个单元测试类的超时时间?
- 23. WebStorm运行所有飞镖单元测试
- 24. 飞镖单元测试:orderedEquals与Batman蝙蝠侠
- 25. 将超时设置为Qt测试
- 26. Qt单元测试设置
- 27. 使用聚合物飞镖测试1.0
- 28. 测试 - 飞行应用程序beta测试时间限制
- 29. CakePHP 3:设置单元测试的当前时间
- 30. 如何FakeHttpContext设置Request.Header单元测试
这是所有测试的全球设置,对不对?目前我们无法设置指定测试的超时时间。 – Freewind
@Freewind我添加了每个测试超时的示例。到目前为止,不知道是否有情况下没有。刚发明它;-) –