Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Unified Diff: pkg/unittest/lib/src/test_case.dart

Issue 416133002: Abort unit tests in the event of async failure while awaiting a future. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update pubspec and changelog Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/unittest/CHANGELOG.md ('k') | pkg/unittest/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/test_case.dart
diff --git a/pkg/unittest/lib/src/test_case.dart b/pkg/unittest/lib/src/test_case.dart
index 03eafd290d6211b421dccba4135c292c7e08559f..fe0d12de644455db83b0e0d5803a06f5a50d17b6 100644
--- a/pkg/unittest/lib/src/test_case.dart
+++ b/pkg/unittest/lib/src/test_case.dart
@@ -99,7 +99,14 @@ class TestCase {
_startTime = new DateTime.now();
_runningTime = null;
++_callbackFunctionsOutstanding;
- return _testFunction();
+ var testReturn = _testFunction();
+ // If _testFunction() returned a future, we want to wait for it like we
+ // would a callback, so if a failure occurs while waiting, we can abort.
+ if (testReturn is Future) {
+ ++_callbackFunctionsOutstanding;
+ testReturn.catchError(_errorHandler('Test'))
+ .whenComplete(_markCallbackComplete);
+ }
}).catchError(_errorHandler('Test')).then((_) {
_markCallbackComplete();
if (result == null) {
« no previous file with comments | « pkg/unittest/CHANGELOG.md ('k') | pkg/unittest/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698