Index: pkg/unittest/lib/src/test_case.dart |
=================================================================== |
--- pkg/unittest/lib/src/test_case.dart (revision 19336) |
+++ pkg/unittest/lib/src/test_case.dart (working copy) |
@@ -78,7 +78,12 @@ |
Future _runTest() { |
_prepTest(); |
+ // Increment/decrement callbackFunctionsOutstanding to prevent |
+ // synchronous 'async' callbacks from causing the test to be |
+ // marked as complete before the body is completely executed. |
+ ++callbackFunctionsOutstanding; |
var f = test(); |
+ --callbackFunctionsOutstanding; |
if (f is Future) { |
f.then((_) => _finishTest()) |
.catchError((e) => fail("${e.error}")); |
@@ -204,4 +209,10 @@ |
void error(String messageText, [String stack = '']) { |
_complete(ERROR, messageText, stack); |
} |
+ |
+ void markCallbackComplete() { |
+ if (--callbackFunctionsOutstanding == 0 && !isComplete) { |
+ pass(); |
+ } |
+ } |
} |