Commit 0f1dee5f authored by Ian Hickson's avatar Ian Hickson

Always dump (unwanted) exceptions during tests (#3344)

...even if the test fails.
parent 0e9737e4
...@@ -169,8 +169,8 @@ class ElementTreeTester extends Instrumentation { ...@@ -169,8 +169,8 @@ class ElementTreeTester extends Instrumentation {
void testElementTree(callback(ElementTreeTester tester)) { void testElementTree(callback(ElementTreeTester tester)) {
new FakeAsync().run((FakeAsync async) { new FakeAsync().run((FakeAsync async) {
FlutterExceptionHandler oldHandler = FlutterError.onError; FlutterExceptionHandler oldHandler = FlutterError.onError;
ElementTreeTester tester = new ElementTreeTester._(async);
try { try {
ElementTreeTester tester = new ElementTreeTester._(async);
FlutterError.onError = (FlutterErrorDetails details) { FlutterError.onError = (FlutterErrorDetails details) {
if (tester._pendingException != null) { if (tester._pendingException != null) {
FlutterError.dumpErrorToConsole(tester._pendingException); FlutterError.dumpErrorToConsole(tester._pendingException);
...@@ -196,12 +196,14 @@ void testElementTree(callback(ElementTreeTester tester)) { ...@@ -196,12 +196,14 @@ void testElementTree(callback(ElementTreeTester tester)) {
return async.nonPeriodicTimerCount == 0; return async.nonPeriodicTimerCount == 0;
}); });
assert(async.microtaskCount == 0); // Shouldn't be possible. assert(async.microtaskCount == 0); // Shouldn't be possible.
if (tester._pendingException != null) { if (tester._pendingException != null)
FlutterError.dumpErrorToConsole(tester._pendingException);
throw 'An exception (shown above) was thrown during the test.'; throw 'An exception (shown above) was thrown during the test.';
}
} finally { } finally {
FlutterError.onError = oldHandler; FlutterError.onError = oldHandler;
if (tester._pendingException != null) {
FlutterError.dumpErrorToConsole(tester._pendingException);
tester._pendingException = null;
}
} }
}); });
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment