Integration Tests
An integration test (also called end-to-end testing or GUI testing) runs the full app.
Write test
Here we are starting the app, and we are pushing frames until the navigation to the root widget has been completed. Then we are searching for the HomeWidget. Just follow the official documentation of widget testing to perform any UI related interactions.
import 'package:example/main.dart' as app;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'package:m8ty_test/home_page.dart';
void main() {
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
group('end-to-end test', () {
testWidgets('tap on the floating action button, verify counter', (tester) async {
app.main();
await tester.pumpAndSettle(const Duration(seconds: 3));
// Verify that platform version is retrieved.
await expectLater(
find.byWidgetPredicate(
(Widget widget) => widget is HomePage,
),
findsOneWidget,
);
});
});
}
Last modified: 10 December 2023