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
11
votes
9 answers

ERROR in flutter: widget_test.dart cannot detect MyApp()

Being a total beginner I am trying out various flutter feature and I am stuck at running the main.dart due to errors in the widget_test.dart file. Please point out if the error is due to some other reason. main.dart import…
joel
  • 263
  • 1
  • 5
  • 16
11
votes
1 answer

Flutter Google Play Console Resource Name for Tests

I developed an app in Flutter and I'm posting to Google Play, though, I would like to know how / where I can set the widget name information so that I can enter as login credentials on the Play Console for automated tests / captures (the image shows…
Augusto
  • 193
  • 1
  • 2
  • 15
10
votes
4 answers

Flutter testing WillPopScope with back button

On my Home widget, when user taps system back button, It shows by a WillPopScope a confirmation dialog widget. I want to test this dialog but I cant figure it out how to press the back button on a test file.
Lucas Pires
  • 103
  • 5
10
votes
2 answers

Flutter Run not working, Error launching application on iPhone

I have updated the flutter version recently. after that flutter run is not working on iPhone. I am using android studio. run button on the android studio also not working for iPhone but simulators are working fine. I am getting the following error.…
Soundhar Raj
  • 177
  • 3
  • 11
10
votes
3 answers

Mock a Widget in Flutter tests

I am trying to create tests for my Flutter application. Simple example: class MyWidget extends StatelessWidget { @override build(BuildContext context) { return MySecondWidget(); } } I would like to verify that MyWidget is actually…
Valentin Vignal
  • 6,151
  • 2
  • 33
  • 73
10
votes
2 answers

Testing/mocking file IO in flutter

I have a simple test: import 'dart:io'; import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; Future main() async { testWidgets( 'Simple empty test', (WidgetTester tester) async { …
user3612643
  • 5,096
  • 7
  • 34
  • 55
10
votes
2 answers

How to access Flutter environment variables from tests?

I've been using flutter_dotenv to load environment variables saved in .env throughout the application and it's worked just fine to date. As I'm trying to write tests though, I cannot seem to access these from a test file. import…
Ross C
  • 143
  • 1
  • 6
10
votes
4 answers

Check for color during widget test?

The goal is to verify the color of a RaisedButton.icon During my widget tests, I have the ability to look for text with find.text as well as icons with find.byIcon. There is no built in method for finding color. How does one do the equivalent of…
LongTSQLFiles
  • 183
  • 2
  • 11
10
votes
3 answers

Widget test a widget which uses WidgetsBinding.instance.addPostFrameCallback()

I'm trying to do a widget test in flutter to one widget which uses WidgetsBinding.instance.addPostFrameCallback() to show a dialog at the very beggining of the widget lifecycle. The widget works fine, but I cannot figure out how to do a widget test,…
svprdga
  • 2,171
  • 1
  • 28
  • 51
10
votes
3 answers

How to add footer to ReorderableListView in flutter

Trying to make a ui that contains Header and Footer with rearrangeable content items. There is a property called header from which we can add header item. But what to do if I want to add footer item as well. import…
jazzbpn
  • 6,441
  • 16
  • 63
  • 99
10
votes
2 answers

How to test ImagePicker in Flutter Driver?

In Flutter integration testing, how can we handle ImagePicker? as well as other platform related plugins?
Frank Yan
  • 371
  • 2
  • 8
10
votes
1 answer

How best to stub/mock rest API calls in Flutter Integration tests

I have a Flutter app that displays data after the user logs in. I have unit and widget tests and now would like to write my first Integration/end-to-end test to test an entire 'happy path' workflow where the user logs in and views the data. When the…
alichur
  • 925
  • 7
  • 19
10
votes
1 answer

Not able to mock singleton class in flutter

I have created a class as singleton making a static method to get the instance of that class but while unit test I am not able to mock that class. Is there any other way in dart to only create a single instance and that can be easily unit tested.
Gagan Garcha
  • 111
  • 1
  • 7
10
votes
2 answers

Can't enter text in flutter test

I've been trying to test an element that when an IconButton is pressed, a Text object changes to a TextFormField. When I try to test this I get the following error: A Timer is still pending even after the widget tree was…
9
votes
5 answers

Parse Issue (Xcode): Module 'fluttertoast' not found (in target 'Toast' from project 'Pods')

Parse Issue (Xcode): Module 'fluttertoast' not found /Users/anand/StudioProjects/untitled/ios/Runner/GeneratedPluginRegistrant.m:11:8 Could not build the application for the simulator. Error launching application on iPhone 11 Pro. I trapped this…
Anand PS
  • 101
  • 2
  • 9