Hot reload for Flutter integration test?


I have setted up Flutter Integration Testing on my project as defined here:

I used the following devDepencendies:

integration_test: ^1.0.0
  sdk: flutter
  sdk: flutter

The test driver is just a C&P from project page:

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();

The final test:

void main() {

    testWidgets('CPCSA-TC-016: Vehicle Card with no alert',
    (WidgetTester tester) async {
        // Execute test code. 

Finally I run my tests with

flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test.dart

Which is basically fine, but it compiles at every execution and this is very time consuming. Is there a chance that I can run the integration test and have the same hot reload feature as I would have for regular development? How to achieve this?

Or is there any other workaround? I am thinking about writing the test code as unit/widget test first and just port it into integration tests once the execution is correct.



It is partly possible with the integration_test package.

With the run command you can at least 🔥Hot Restart – which saves a lot of time when writing the tests.
You are able to make changes to both your project and your test code and have the changes reflected.

From terminal execute:

flutter run integration_test/tests/your_test.dart

You should then be able to Hot Restart (with terminal focused) by pressing SHIFT + r.

It is also possible to add the test file you want to test to your IDEs run configuration and run or DEBUG it from there like a "normal" project.

Example bogus "your_test.dart" test:

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

void main() {
  testWidgets('Test test testing', (WidgetTester tester) async {
    expect(true, isTrue);

Answered By – ninnepinne

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *