Reputation: 566
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);
});
});
}
Upvotes: 0
Views: 509
Reputation: 94
Just change one line:
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
to this:
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
Your tests will be more stable by this.
Upvotes: 1