So I recently wanted to add some integration testing to the my app, and followed the official guidelines from the flutter.dev on the integration testing. I managed to run a single test, so I wanted to add another one, and this is where the problems started.
I don't know how to add another test suite in the same run, so something like
TEST 1:
- click button
- check if counter incremented
TEST2:
- click the button again
- check if counter incremented again
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
group('Integration test', () {
testWidgets('test 1', (WidgetTester tester) async {
app.main();
await tester.pumpAndSettle();
// doing stuff here works
});
});
}
This is what I have working right now. I expected that moving the app.main() call before the group and simply adding another testWidgets call will work (similar to unit testing) but it doesn't:
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
// app.main(); <<--- moving here...
group('Integration test', () {
// app.main(); <<--- ... or here didn't help
testWidgets('test 1', (WidgetTester tester) async {
// do stuff
});
testWidgets('test 2', (WidgetTester tester) async {
// how to add this? And do stuff with the same app session
});
});
}
EDIT: For better clarity of what I'm trying to achieve. The following are some current flutter driver tests that I have. I just want to migrate to the new api of integration_test package, without losing the names "test 1", "test 2" etc
void main() {
group("group name", () {
FlutterDriver driver;
setUpAll(() async {
driver = await FlutterDriver.connect();
});
tearDownAll(() async {
if (driver != null) {
await driver.close();
}
});
test('test 1', () async {
// do stuff with the driver
});
test('test 2', () async {
// do other stuff with the driver with the same seesion
});
test('test 3', () async {
// etc
});
});
}