Developing Integration tests for a Flutter application

NOVASOLUTIONS.TECHNOLOGY is engaged in the development, support and maintenance of iOS, Android, PWA mobile applications. We have extensive experience and expertise in publishing mobile applications in popular markets like Google Play, App Store, Amazon, AppGallery and others.
Development and support of all types of mobile applications:
Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1 servicesAll 1735 services
Developing Integration tests for a Flutter application
Medium
~3-5 business days
FAQ
Our competencies:
Development stages
Latest works
  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    756
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    624
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1050
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    947
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    862
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    445

Developing Integration Tests for Flutter Applications

Integration tests in Flutter run on a real device or emulator. The application starts completely: Dart engine, Flutter Framework, your code. WidgetTester here works on top of real rendering, not synthetic. That's why integration tests find what widget tests miss: issues with navigation between real Routes, animation timing on specific hardware, behavior under low memory.

The integration_test Package

The modern approach — the integration_test package from Flutter SDK (not third-party, official since Flutter 2.5). It replaces the deprecated flutter_driver.

pubspec.yaml:

dev_dependencies:
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter

Directory structure:

integration_test/
  app_test.dart
test_driver/
  integration_test.dart  # only for running via flutter drive

Running on connected device:

flutter test integration_test/app_test.dart

Running in Firebase Test Lab or BrowserStack — through flutter build apk --target integration_test/app_test.dart + APK upload.

What We Test and How

A typical integration test covers a full user flow: opened app → authorized → navigated to catalog screen → added item to cart → completed order → saw confirmation screen.

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets('Full checkout flow', (tester) async {
    app.main();
    await tester.pumpAndSettle();

    // Login
    await tester.enterText(find.byKey(Key('email')), '[email protected]');
    await tester.enterText(find.byKey(Key('password')), 'password123');
    await tester.tap(find.byKey(Key('login_btn')));
    await tester.pumpAndSettle(timeout: Duration(seconds: 10));

    expect(find.byKey(Key('home_screen')), findsOneWidget);

    // Add to cart
    await tester.tap(find.byKey(Key('product_card_1')));
    await tester.pumpAndSettle();
    await tester.tap(find.byKey(Key('add_to_cart_btn')));
    await tester.pumpAndSettle();

    expect(find.text('1'), findsOneWidget); // badge on cart icon
  });
}

pumpAndSettle(timeout: Duration(seconds: 10)) — timeout is necessary. Without it on a slow emulator the test will fail before navigation animation completes.

Parallel Execution

One test file — one device session. For parallel runs create multiple files and run them through a matrix in CI. In GitHub Actions:

strategy:
  matrix:
    test-file: [auth_test.dart, checkout_test.dart, profile_test.dart]
steps:
  - run: flutter test integration_test/${{ matrix.test-file }}

Each job gets its own emulator. AVD Manager through reactivecircus/android-emulator-runner@v2 runs them in parallel.

Working with Real Network Requests

The main choice: test against a real backend or mock the network.

Real backend — need a test environment (staging). Data must be predictable: fixed test accounts, deterministic responses. Network errors make tests unstable.

Mock servermockito/mocktail at the repository level, or local HTTP server through shelf package. The second approach is closer to reality: the application makes a real HTTP request, but to localhost:8080 instead of api.production.com. Switching through environment variable or --dart-define=API_BASE_URL=http://localhost:8080.

Integration Test Instability

Flaky tests in integration_test — common problem. Main causes:

Animations. pumpAndSettle() waits for their completion, but if your app has an infinite animation (loading indicator, lottie animation in background), pumpAndSettle() will hang. Solution: tester.pump(Duration(milliseconds: 500)) with explicit waiting for specific widget through waitFor.

Keyboard. After enterText() system keyboard may cover button. Hide it: await tester.testTextInput.receiveAction(TextInputAction.done) or FocusManager.instance.primaryFocus?.unfocus() before tap().

Test timeout. By default integration test completes in 10 minutes. For long flows increase: @Timeout(Duration(minutes: 5)) above testWidgets.

Timeline

3–5 days for writing integration tests to existing application. Complex flow with authorization, payments, and deep navigation — closer to 5 days. Simple linear scenarios — 3 days. Cost is calculated after architecture audit of the application.