2

In Flutter integration tests, is there any way we can kill the app & reinstall it for every testWidgets?

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets('TC_01 Home page validation', (tester) async {
    app.main();
    await tester.pumpAndSettle(const Duration(seconds: 5));

    await tester.tap(find.byKey(const ValueKey('startButton')));
    await tester.pumpAndSettle();
  });

  testWidgets('TC_02 Home page text validation ', (tester) async {
    app.main();
    await tester.pumpAndSettle(const Duration(seconds: 5));
    expect(find.text('Home Screen'), findsOneWidget);
    expect(find.text('Transactions'), findsOneWidget);
  });
}

I want to reinstall the app for every new test that runs.

My Car
  • 4,198
  • 5
  • 17
  • 50
Jagadeesh
  • 358
  • 5
  • 17

1 Answers1

0

This is not possible, because, in Flutter, the tests (integration tests included) live inside your app. If you uninstalled the app after the first test passed, you'd also uninstall the test suite (which runs inside your app) - which doesn't make sense.

A better question is to ask: what do you want to achieve? If you want to reset state, you can pump your app once again and it will reset the whole widget tree, along with all blocs/providers you might've created.

Bartek Pacia
  • 1,085
  • 3
  • 15
  • 37