flutterflutter2.0flutter-integration-test

How to do multiple files of integration tests in flutter 2?


I'm trying to create an integration test for my Flutter app with new integration_test package: https://github.com/flutter/flutter/tree/master/packages/integration_test#integration_test

I have multiple files of integration tests, like:

integration_test/
   login_test.dart
   logout_test.dart
   run_all_test.dart
test_driver/
   integration_test.dart

I want to run the login and logout tests sequentially, using the run_all_test.dart

In run_all_test.dart script I have:

void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized() as 
IntegrationTestWidgetsFlutterBinding;
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;

app.main();

group('All tests', () {
loginTest();
logoutTest();
});

and login_test.dart is like this (logout_test.dart is the same):

void main() {
loginTest();
}
Future<void> loginTest() async {
group('Login - ', (){
testWidgets("Login test", (WidgetTester tester) async {
  await ...
   });
 });
} 

Now, login works perfectly and, when he is done, starts the logout test but, at this moment, the app is waiting with the message "Test starting .." and then fails.

With the old package, everything worked perfectly and, between one test and another, the app was not restarted.


Solution

  • I solved adding:

    await tester.pumpFrames(app.MyApp(), Duration(seconds: 3));
    

    in all test files.