-
Notifications
You must be signed in to change notification settings - Fork 27.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The following assertion was thrown running a test: 'package:flutter_test/src/binding.dart': Failed assertion: line 567 pos 14: '_pendingExceptionDetails != null' #34499
Comments
Reproduces with current master flutter doctor -v
|
I'm facing such error when the "expect()" fails during running integration tests (migrated from flutter_driver to new API) via CLI command "flutter drive --driver=test_driver/integration_test.dart --target=integration_test/smoke_test.dart" instead of telling what went wrong (I mean "Expected:" and "Actual:"): [ERROR:flutter/shell/common/shell.cc(210)] Dart Unhandled Exception: 'package:flutter_test/src/binding.dart': Failed assertion: line 754 pos 14: '_pendingExceptionDetails != null': A test overrode [✓] Flutter (Channel stable, 1.22.5, on macOS 11.1 20C69 darwin-x64, locale en-GB) |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as duplicate.
This comment was marked as duplicate.
Flutter team, please help us with this problem, because it is not informative and brings much more time to debug integration tests. Also, it is reproducible on the latest stable Flutter: [✓] Flutter (Channel stable, 2.2.3, on macOS 11.5.1 20G80 darwin-x64, locale en-UA) I/flutter (22828): Another exception was thrown: Expected: exactly one matching node in the widget tree |
Hope the Flutter team can take a look at this issue soon because all errors seem to output the error above instead of the correct error stack. Trying to do what the error says and resetting FlutterError.onError did not work for me.
|
On flutter 2.5.0 this seems to be fixed. It no longer gets stuck when running the test. So it continues to execute the rest of the tests. Although it still shows the |
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
testWidgets("my test", (WidgetTester tester) async {
await app.main();
await tester.pumpAndSettle();
expect(true, false);
});
} This doesn't fail for me but will result in a time out. This doesn't make any sense to me really. The failure is inside |
@Jonas-Sander is it on flutter 2.5.0? You sample code indeed timed out when I was trying on 2.2.0, but on the 2.5.0 it correctly fails, and move along |
Ah yeah I'm still on 2.2.0, got a bit confused with the versions, sorry :) |
Same problem on widget testing, no way to catch a future error with FutureBuilder without fail the test (except if the future is launch during initial build). See #91495 |
This happens also on integration tests, I think we should add the label |
It happens on integration tests. Actually its possible to pass only happy path. Any updates? |
Any updates? |
it helped me to comment out the override of FlutterError.onError in my App |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
i was struggling with this error (flutter 3.0.1) because i thought maybe an unhandled error was causing this. however, i fixed it by wrapping the |
@jrc2139 - Unfortunately it doesn't work for me :( |
you could try adding an isolate to catch an error as well
|
Where should I put this code? |
I found this issue when running integration test on Flutter 3.0.0, and I fixed it like this:
|
This comment was marked as duplicate.
This comment was marked as duplicate.
I fixed the issue by using the "Invalidate Caches..." Option from the File menu drop-down in Android Studio. |
This comment was marked as duplicate.
This comment was marked as duplicate.
Unfortunately this doesn't work for me. I am using Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-IN) |
Unfortunately this doesn't work for me. I am using Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-IN) |
I have tried that same with flutter 3.0.4, it seems to be working right. |
I have tried that same with flutter 3.0.4, it seems to be working fine. |
Also have this iss on flutter |
I'm on //file: utils/integration_test_helpers.dart
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
var _originalOnError;
void initCustomExpect() {
_originalOnError = FlutterError.onError;
}
// A workaround for: https://github.com/flutter/flutter/issues/34499
void expectCustom(
dynamic actual,
dynamic matcher, {
String reason,
dynamic skip, // true or a String
}) {
final onError = FlutterError.onError;
FlutterError.onError = _originalOnError;
expect(actual, matcher, reason: reason, skip: skip);
FlutterError.onError = onError;
} and then in my integration tests: import 'utils/integration_test_helpers.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('end-to-end test', () {
testWidgets('app loads and home screen is shown', (tester) async {
// I call this at the top of each test
initCustomExpect();
app.main();
await tester.pumpAndSettle();
// For the remainder of the test, I just use my custom expect
expectCustom(find.text('hello'), findsOneWidget);
});
});
} Now the nasty exception is gone and I get the actual exception like how it should be. |
Verified this issue on latest stable and master versions using below updated code sample and observed that the error still occurs: console error log
runnable code sample
stable, master flutter doctor -v
|
I'm still seeing this too. |
I'm facing this issue too, any help please ? |
This worked for me on Flutter 3.3.10 stable channer.. Tks |
The code snippet in #34499 (comment) shows how to do this correctly. |
@goderbauer but this is still a workaround because we need to add this in every test which needs |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to Reproduce
(see full code)
FutureBuilder
and initialize aFuture
that will throw an exception.testWidgets
that taps the button and overrideFlutterError.onError
to test the exception thrown.Logs
flutter analyze
flutter doctor
The text was updated successfully, but these errors were encountered: