Questions tagged [flutter-test]

Flutter-Test contains tests related to Flutter app including Unit tests, Widget test and end-to-end integration tests using Flutter-Driver.

Flutter officially highlights 3 different types of testing as mentioned here: https://flutter.dev/docs/testing

Unit tests: A unit test tests a single function, method, or class.

Widget tests: A widget test (in other UI frameworks referred to as component test) tests a single widget.

Integration tests: An integration test tests a complete app or a large part of an app.

1961 questions
18
votes
6 answers

flutter error: This widget has been unmounted, so the State no longer has a context (and should be considered defunct)

when I clicking on login button when my mobile number is wrong then open one error dialog box after that when I clicked okey on dialog box then i got this error. I got this message This widget has been unmounted, so the State no longer has a…
Deepak
  • 1,664
  • 3
  • 19
  • 52
18
votes
4 answers

Flutter widget test Finder fails because the widget is outside the bounds of the render tree

Question: What controls the bounds of the "render tree" when running widget tests (flutter_test)? I ask because I am getting an error on very basic button where it can't find the widget because of its vertical offset being outside the bounds of the…
TommyLCox
  • 243
  • 1
  • 2
  • 7
18
votes
4 answers

How to run flutter on chrome using visual code editor

How to run flutter app on chrome. I have installed flutter kit and also run flutter channel beta flutter upgrade and also install extension on visual studio code.
Pradeep Yadav
  • 201
  • 1
  • 2
  • 5
18
votes
2 answers

In a Flutter widget test, how can I verify a field validation error message?

I'm writing a widget test for a Flutter form, and want to verify that after form submission, validation fails, and errorText for one of the fields is displayed and is as expected. The code for the field looks like: Form(key: _formKey, ... …
Matt R
  • 9,892
  • 10
  • 50
  • 83
17
votes
5 answers

how to restore FlutterError.onError?

In my app, I record the flutter onError to crashalytics, FlutterError.onError = FirebaseCrashlytics.instance.recordFlutterError; While running the integration test, if some exceptions happens I get the below statement in the console and the test…
MeanMan
  • 1,040
  • 10
  • 25
17
votes
5 answers

New integration_test package just shows "Test starting..." [Android]

I tried to migrate my old flutter driver tests to the new integration_test package. I copied nearly everything from the example project and executed the integration tests of the example project locally. That worked as expected, I was able to see the…
Andreas B.
  • 171
  • 1
  • 3
17
votes
1 answer

How to check if widget is visible using FlutterDriver

I am not sure how I would check whether a widget is currently shown or not using FlutterDriver. Using WidgetTester this is really easy to perform using e.g. findsOneWidget. However, during integration tests using FlutterDriver, there is no access to…
creativecreatorormaybenot
  • 114,516
  • 58
  • 291
  • 402
17
votes
1 answer

How can I generate test coverage of untested files on my flutter tests?

I'm making Widget and Unit testing on my app, I make the tests normally, according to the basic guides, and to generate the coverage I use: flutter test --coverage However I just can see the coverage of the files directly tested, I'd like to see the…
Felipe Augusto
  • 7,733
  • 10
  • 39
  • 73
17
votes
1 answer

How to wait for a future to complete in Flutter widget test?

I am trying to perform a widget test, specifically navigation test. I am using bloc architecture, setting a stream on the bloc triggers a series of events inside the bloc, gets session info from the server call (which returns a future of session…
ssiddh
  • 480
  • 1
  • 6
  • 18
17
votes
3 answers

Testing Flutter code that uses a plugin and platform channel

I have a flutter plugin which uses the platform channel to do some native work. How do I properly write tests for my application that requires this plugin? Unit tests only are good for pure dart functions. I don't believe Widget testing will be able…
James
  • 693
  • 1
  • 13
  • 27
16
votes
1 answer

Flutter: Timer Issue During Testing

I have a periodic timer in one of my StatelessWidget's. Without going too much into detail, here is a snippet of code producing a timer: class AnniversaryHomePage extends StatelessWidget { . . . void _updateDisplayTime(StoreInheritedWidget…
Josh
  • 2,232
  • 3
  • 15
  • 33
15
votes
6 answers

How to fix this error Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'.?

When i tried to run the app I'm getting this error Task 'assembleAarRelease' not found in root project 'flutter_plugin_android_lifecycle'. how to rectify this?
Akshay gopan
  • 161
  • 1
  • 2
  • 4
15
votes
1 answer

How to unit test Stream.listen() in Dart

Consider the following test code ... main() { StreamController controller; setUp(() { controller = StreamController.broadcast(sync: false); }); tearDown(() { controller.close(); }); test('Stream listen test', () { var…
ra9r
  • 4,528
  • 4
  • 42
  • 52
14
votes
1 answer

Can't found widget key flutter test

So, i'm trying to test my flutter app. Here is what i do class MockSplashScreenBloc extends MockBloc implements SplashScreenBloc {} void main() { MockSplashScreenBloc splashScreenBloc; Widget MyWidget() { return…
NewbiewDev
  • 202
  • 2
  • 7
14
votes
2 answers

DTDeviceKit: deviceType Null

initiated 'flutter run' in VS code and getting the following error: 2020-05-02 16:23:57.827 xcodebuild[97219:3069326] DTDeviceKit: deviceType from 00008030-000D35311160802E was NULL Any suggestions on what this means?
KirtM9
  • 231
  • 4
  • 19