D
TestingMedium30 XP4 min read

How does the integration_test package work?

TL;DR: integration_test runs tests inside the Flutter app on a real or emulated device. Tests share the same process as the app, enabling full state access. Run with flutter test integration_test/ or flutter drive.

Full Answer

The integration_test package (officially supported by Google) replaced flutter_driver as the recommended way to write end-to-end tests.

Key Differences from Widget Tests

  • Runs on a real device or emulator
  • Full app is initialized (main() is called)
  • Network calls, filesystem, platform channels all work
  • Slower (seconds per test) but most realistic
🎯

Use integration_test with firebase_test_lab or Sauce Labs for matrix testing across real devices in CI.

Code Examples

dartBasic integration test
Output
// Run: flutter test integration_test/
// Or: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart

Common Mistakes

  • Writing integration tests for everything — use them only for critical user flows
  • Hardcoding wait times with Future.delayed instead of pumpAndSettle()

Interview Tip

💡

Mentioning Firebase Test Lab for running integration tests on real devices in CI shows you've thought about test infrastructure, not just writing tests.

#integration-test#driver#device-testing#flutter-drive