Always dump (unwanted) exceptions during tests (#3344)
...even if the test fails.
This commit is contained in:
parent
0e9737e4cc
commit
0f1dee5f46
@ -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)) {
|
|||||||
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user