How to run integration tests on Flutter apps

On This Page Introduction To FlutterFeatures of Flutter Framework

June 09, 2026 · 9 min read · Testing Guide

How to run integration tests on Flutter apps

Flutter, designed by Google, is a free and open-source framework for building visually appealing, natively collect, and multi-platform applications from a individual codebase.

Flutter has become rather democratic due to its power to create multi-platform apps. It enable users to build, deploy, and test web, mobile, desktop, and embedded application from a single codebase.

Overview

Features of Flutter Framework:

  • Fast Development with Hot Reload
  • Multi-Platform Support
  • Modern and Reactive Framework
  • Easy-to-Learn Dart Language
  • Fluid and Intuitive UI
  • Extensive Widget Catalog
  • Ordered UI Across Platforms
  • Robust Performance and Stability

Steps To Perform Integration Testing In Flutter Apps

  • Create an app to test
  • Add the integration_test dependency
  • Create the test files
  • Write the integration test
  • Run the integration examination

This clause research the Flutter framework and how to run integration tests on Flutter apps.

Introduction To Flutter

Flutteris an open-source mobile UI framework that can create Android and iOS apps (among other program) from a single codebase.

Generally, frameworks offer different features to develop mobile application. For example, Android provide a framework based onJava and Kotlinto acquire mobile apps, whereas iOS uses a framework based onObjective-C or Swift language.

As a result, Devs had to use two different languages and frameworks to develop applications for both OS. Naturally, a cross-platform framework like Flutter makes life simpler for them by saving resource, time, and effort.

Features of Flutter Framework

Here are some of the key features that set Flutter apart:

  • Facilitates fast development: Flutter accelerates coding with hot reload, countenance instant optic feedback.
  • Multi-Platform support: It enables building apps for Android, iOS, web, and background from a individual codebase.
  • Provides a modern and responsive framework: Flutter & # 8217; s widget-driven, responsive architecture simplifies dynamic UI conception.
  • Uses the easy to learn Dart program speech: The intuitive Dart words offers a suave encyclopedism curve for developers.
  • Fluid and intuitive user interfaces: It render visually appealing and responsive interfaces for an optimal user experience.
  • Vast doodad catalog: An extensive array of customizable thingmabob empowers rich, tailored app designs.
  • Runs the same UI for multiple platforms: Flutter ensures reproducible user interfaces across all supported platforms.
  • Stable and Reliable: The framework is renowned for its robust performance and dependable stableness.

Testing In Flutter Apps

Flutter support three types of tests:

  • : A unit test verifies the behavior of a method or class.
  • Widget Test: A gubbins test checks the demeanour of Flutter widgets without having to run the app.
  • : An integrating test (besides called end-to-end testing or GUI examine) runs the entire application.

Integration Testing In Flutter Apps

Unit tests and Widget tests can essay individual classes, widgets, or functions. However, they don ’ t verify how individual component work together or monitor application performance on real devices. This is where integration tests come in.

Integration tryout in Flutter are written apply theconsolidation testpackage, provide by the SDK. This is Flutter & # 8217; s version of (generic web), Protractor (Angular),, or Earl Gray (iOS). The parcel internally usesflutter driverto drive the exam on a device.

Tests written with theintegration_testpackage can:

  1. Run straightaway on the mark device, enabling trial on numerous Android or iOS device.
  2. Run using flutter trial integration_test.
  3. Use flutter_testAPIs, which makes the conception of integration tests similar to creatingwidget examination.

Talk to an Expert

Migrating From Flutter Driver

When Flutter was introduced, integration tests were written usingflutter_driver, which enable testers to sustain programmatic control of a Flutter app. On run the futter cause command, it initiates 2 processes:

  • A & # 8220; driver & # 8221; process on the host machine (i.e. the developer & # 8217; s laptop) that sends instructions to and receives data from the app.
  • The app is configure to identify connections coming from the driver process.

This allowed the developer to write tests in plain Dart that could interact with the app. However, it came with significant disadvantages:

  • The driver code couldn & # 8217; t share any code with the appor unit tests. In fact, it couldn & # 8217; t leverage anypacket: waverdependence.
  • It relied on strongly-typed APIsbecause it could not import Key, Widget, or MyCustomWidget.find.byType (& # 8216; EvnetsPage & # 8217;)was often mistyped and misread

Integration_Test Package

SUSA automates exploratory testing with persona-driven behavior, catching bugs that scripted automation misses.

The integration_test parcel was released to fix some of the issue mention above. Here, the code for tests runs in the same isolate as the app code itself. In other language, it can access the like memory. This basically resolves the previous issues, and offers a few early benefits:

  • Same API as ingredient tests.
  • Can share code with the app.
  • Internal app state is whole visible to examination, and runApp is called inside the test.
  • Since test are make into the app executable, they can now run on physical devices.

Steps To Perform Integration Testing In Flutter Apps

This example will demonstrate how to test a tabulator app. This establish how to set up integrating tryout, how to verify if a specific text is being displayed by the app, how to tap specific widgets, and how to run integration tests.

In order to execute the Integration test, follow the below steps:

  1. Create an app to test.
  2. Add the integration_test dependency.
  3. Create the test files.
  4. Write the integration test.
  5. Run the integration test.

Step 1. Create an app to test

First, create an app for testing. This tryout will use a tabulator app produced by thedisruption createbid. This app will let a user tap on a button to increase one tally.

import 'package: flutter/material.dart ';



void main() => runApp(const MyApp());



class MyApp extends StatelessWidget {const MyApp({Key? key}) : super(key: key);@overrideWidget build(BuildContext context) {return const MaterialApp(



      title: 'Counter App ',



      home: MyHomePage(title: 'Counter App Home Page '),);}



}



class MyHomePage extends StatefulWidget {const MyHomePage({Key? key, required this.title}) : super(key: key);final String title;@override_MyHomePageStatecreateState() => _MyHomePageState();



}



class _MyHomePageState extends State<MyHomePage> {int _counter = 0;void_incrementCounter() {



    setState(() {



      _counter++;});}@overrideWidget build(BuildContext context) {return Scaffold(



      appBar: AppBar(



        title: Text(widget.title),),



      body: Center(



        child: Column(mainAxisAlignment: MainAxisAlignment.center,



          children: <Widget>[const Text('You have force the button this many times: ',),Text(' $ _counter ',// Provide a Key to this specific Text widget. This allows// identifying the widget from inside the test suite,// and read the text.



              key: const Key('counter'),



              style: Theme.of(context).textTheme.headline4,),],),),floatingActionButton: FloatingActionButton(// Provide a Key to this button. This let chance this// specific button inside the test suite, and tapping it.



        key: const Key('increment '),



        onPressed:_incrementCounter,



        tooltip: 'Increment ',



        child: const Icon(Icons.add),),);}



}

Step 2. Add the integration_test dependency

Now, use theintegration_test, flutter_driver, and flutter_testpackages for writing integration tests.

Add these dependencies to thedev_dependenciessection of the app ’ spubspec.yamlfile. The location of the package should be the Flutter SDK.

# pubspec.yamldev_dependencies:integration_test:



    sdk:flutter flutter_test:



    sdk: flutter

Step 3. Create the exam file

Create a new directory,integration_test, with an empty-belliedapp_test.dart file:

counter_app/



  lib/



    main.flit integration_test/



    app_test.dart

Step 4. Write the integration exam

Now, compose the integration test with the measure below:

  1. InitializeIntegrationTestWidgetsFlutterBinding, a singleton service that runs tests on a physical gimmick.
  2. Interact and test widgets via theWidgetTesterclass.
  3. Test the necessary scenarios.
import 'package: flutter_test/flutter_test.dart ';



import 'package: integration_test/integration_test.dart ';



import 'package: introduction/main.dart ' as app;



void main() {IntegrationTestWidgetsFlutterBinding.ensureInitialized();group('end-to-end examination ', () {testWidgets('tap on the floating activity push, verify counter ',(WidgetTester tester) async {



      app.main();await tester.pumpAndSettle();// Verifies that the counter starts at 0.



      expect(find.text('0'),findsOneWidget);// Finds the floating action button to tap on.final Finder fab = find.byTooltip('Increment ');// Emulates a tap on the floating activeness button.await tester.tap(fab);// Triggers a frame.await quizzer.pumpAndSettle();// Verifies if the tabulator growth by 1.



      expect(find.text('1'),findsOneWidget);});});



}

Step 5. Run the integration exam

The process of fulfill desegregation tests depends greatly on the platform used. If the program so permits, You can test on roving devices or web browsers.

Mobile

To test on a real iOS / Android gimmick, foremost, connect the device and run the following command from the root of the project:

flutter test integration_test/app_test.dart

Or, specify the directory to run all integration tests:

flutter examination integration_test

This command runs the app and integration tests on the target twist.

Web

To essay on a web browser (Chrome, in this example),Download ChromeDriver.

Next, make a new directory namedtest_drivermoderate a new file namedintegration_test.dart:

import 'package: integration_test/integration_test_driver.dart ';



Future& lt; void & gt; main() =>integrationDriver();

Launch WebDriver, for example:

chromedriver--port=4444

From the root of the project, run the next command:

flutter drive \--driver=test_driver/integration_test.dart \



  --target=integration_test/app_test.dart \



  -d web-server

Common Mistakes to avoid in Flutter Integration Testing

Here are some mutual mistakes to watch out for when writing Flutter integration trial:

  • Neglecting Asynchronous Operations: Failing to properly wait for spiritedness, mesh responses, or state updates can lead to flaky tests that pass intermittently.
  • Hardcoding Widget Identifiers: Relying on fixed contrivance keys or text value makes tests brittle and susceptible to breakage during UI refactoring.
  • Overcomplicating Test Scenarios: Trying to continue too many features in a individual test can obscure the root campaign of failures and complicate debugging.
  • Insufficient Cleanup Between Tests: Not resetting the app province or cleaning up resources after each trial can lead to mutualist tests and unpredictable results.
  • Poor Error Handling and Logging: Overlooking the use of logging or error capture mechanisms can make it difficult to diagnose failures when they happen.
  • Ignoring Platform Differences: Failing to report for platform-specific conduct may result in tests that pass in one environs but fail in another.
  • Not Integrating with CI/CD Pipelines: Skipping mechanisation in your continuous integration setup can cause fixation to go unnoticed until much subsequently in the development round.

Integration Tests In Flutter Apps With BrowserStack

In order to get the virtually out of Integration tests, tests must be run on multiple existent device, program, and OS combination. You can not comprehensively and accurately identify all possible glitch without screen apps in, and that is where BrowserStack come in.

Read More:

BrowserStack ’ s offers K of real mobile devices from major vendor and manufacturers for app testing (manual and automated). Each device is loaded with existent operating systems – multiple versions of popular go systems in use.

Conclusion

With BrowserStack, QAs can access yard of popular wandering device-OS combinations to essay their app and script their automation cases without worrying about purchasing and updating device and instal software. They just want to, choose the mandatory device-OS combination and start test their app.

Tags
98,000+ Views

# Ask-and-Contributeabout this subject with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free