0

Hello currently we are working on a big project with my teammates. And we are having issues with automating our testing.

We are building integration tests, but for whatever reason tests sometimes work and sometimes get stuck, it just gets stuck when we run integration test on Emulator/Simulator with no log, but sometimes it just works perfectly, I want to know if our implementation is wrong or Flutter integration tests in general behaving like this.

Here is the code example of our generic test:

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

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  setUpAll(
    () {},
  );
  tearDownAll(
    () async {},
  );
  group('end-to-end test', () {
    testWidgets('Check route based on session', (tester) async {
      
      await tester.runAsync(() async {
        await app.main();
        await tester.pumpAndSettle();
        // We tried to fix stuck bug by waiting 3 secs, it didn't work.
        await tester.pump(const Duration(seconds: 3));
      });

      var jwt = await secureStorage().read(key: "token");

      logIt().d(jwt);

      // if jwt is null there should be a splashpage if not null splashpage should not be there
      expect(find.byType(SplashPage, skipOffstage: false),
          jwt == null ? findsOneWidget : findsNothing);
    });
  });
}
Umut Arpat
  • 454
  • 1
  • 6
  • 18
  • I don't think you should be awaiting the call to app.main(). And why are you using tester.runAsync? – John Weidner Aug 31 '23 at 15:17
  • It might be due to your low disk space. Kindly check whether your disk has enough space for the emulator to run. This happened to me once and I rectified by removing unnecessary files from my disk – Dinesh Kumar M Aug 31 '23 at 18:21

0 Answers0