How to know which test is throwing after it completes in flutter?

Viewed 31

I have alot of tests in a project. When I run flutter test, all the tests pass, but I get this error in the console:

══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
The following assertion was thrown running a test (but after the test had completed):
Looking up a deactivated widget's ancestor is unsafe.
At this point the state of the widget's element tree is no longer stable.
To safely refer to a widget's ancestor in its dispose() method, save a reference to the ancestor by
calling dependOnInheritedWidgetOfExactType() in the widget's didChangeDependencies() method.

When the exception was thrown, this was the stack:
#0      Element._debugCheckStateIsActiveForAncestorLookup.<anonymous closure> (package:flutter/src/widgets/framework.dart:4241:9)
#1      Element._debugCheckStateIsActiveForAncestorLookup (package:flutter/src/widgets/framework.dart:4255:6)
#2      Element.dependOnInheritedWidgetOfExactType (package:flutter/src/widgets/framework.dart:4275:12)
#3      Localizations.of (package:flutter/src/widgets/localizations.dart:472:48)
#4      AppLocalizations.of (package:flutter_gen/gen_l10n/app_localizations.dart:68:26)
#5      ScreenshotCubit._captureWidget (package:photo_editor/ui/screens/editor_screen/bloc/screenshot_cubit/screenshot_cubit.dart:175:51)
<asynchronous suspension>
════════════════════════════════════════════════════════════════════════════════════════════════════

I know the reason of it, a test is trying to get a string from the AppLocalizations after the context is no longer available (mounted). But the message does not give any info about which test is causing the error. So how can I know which one is it without having to run the tests one by one?

Update:

I ran the tests in groups and narrowed the problem to one group.

But now when running the tests in the whole group in android studio I get the exception (all the tests pass).

But if I run the same tests one by one, all of them pass, and no one gives this exception.

Can someone explain to me how to solve this?

0 Answers
Related