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我添加了每個測試超時的示例。到目前爲止,不知道是否有情況下沒有。剛發明它;-) –