Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit a65deb4

Browse files
committed
[e2e] Fix overly verbose stack traces in test failures
We need to reset `reportTestException` back to the previous value after completion of `runTest`, or repeated failures will cause the exception handler for a previous test to be invoked, as they "stack". Instead of reseting it, however, do this once in the constructor because the test description is already provided by the function signature.
1 parent 3b931d0 commit a65deb4

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

packages/e2e/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.0+1
2+
3+
* Fix overly verbose stack traces in test failures
4+
15
## 0.6.0
26

37
* **Breaking change** `E2EPlugin` exports a `Future` for `testResults`.

packages/e2e/lib/e2e.dart

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
3939
}
4040
if (!_allTestsPassed.isCompleted) _allTestsPassed.complete(true);
4141
});
42+
43+
// TODO(jackson): Report the results individually instead of all at once
44+
// See https://github.com/flutter/flutter/issues/38985
45+
final TestExceptionReporter oldTestExceptionReporter = reportTestException;
46+
reportTestException =
47+
(FlutterErrorDetails details, String testDescription) {
48+
_results[testDescription] = 'failed';
49+
_failureMethodsDetails.add(Failure(testDescription, details.toString()));
50+
if (!_allTestsPassed.isCompleted) {
51+
_allTestsPassed.complete(false);
52+
}
53+
oldTestExceptionReporter(details, testDescription);
54+
};
4255
}
4356

4457
// TODO(dnfield): Remove the ignore once we bump the minimum Flutter version
@@ -120,18 +133,6 @@ class E2EWidgetsFlutterBinding extends LiveTestWidgetsFlutterBinding {
120133
String description = '',
121134
Duration timeout,
122135
}) async {
123-
// TODO(jackson): Report the results individually instead of all at once
124-
// See https://github.com/flutter/flutter/issues/38985
125-
final TestExceptionReporter oldTestExceptionReporter = reportTestException;
126-
reportTestException =
127-
(FlutterErrorDetails details, String testDescription) {
128-
_results[description] = 'failed';
129-
_failureMethodsDetails.add(Failure(testDescription, details.toString()));
130-
if (!_allTestsPassed.isCompleted) {
131-
_allTestsPassed.complete(false);
132-
}
133-
oldTestExceptionReporter(details, testDescription);
134-
};
135136
await super.runTest(
136137
testBody,
137138
invariantTester,

packages/e2e/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: e2e
22
description: Runs tests that use the flutter_test API as integration tests.
3-
version: 0.6.0
3+
version: 0.6.0+1
44
homepage: https://github.com/flutter/plugins/tree/master/packages/e2e
55

66
environment:

0 commit comments

Comments
 (0)