You may trying to run all test-case from one file. it may help, though its late replay.
Suppose you have 3 test file which is,
- login.dart and login_test.dart (where all the test-case has to be written in
login_test.dart
)
- register.dart and register_test.dart
- forgotPassword.dart and forgotPassword_test.dart
Put all those test-cases into a main function. (describing only one test file code[login_test.dart]
)
main(){
loginTest();
}
Future<void> loginTest()async{
group('Login Page Automation Test :', () {
//Write your test-cases here
}
so, now create a test file and call all the main functions on that file, which will be used to run all cases at once.
testAll.dart & testAll_test.dart
Write in these format on testAll_test.dart
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
import 'login_test.dart';
import 'register_test.dart';
import 'forgotPassword_test.dart';
main() {
testAll();
}
Future<void> testAll() async {
group('All TestCase at Once: ', () {
//code here
FlutterDriver driver;
// Connect to the Flutter driver before running any tests.
setUpAll(() async {
driver = await FlutterDriver.connect();
});
// Close the connection to the driver after the tests have completed.
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
//main methods below
forgotPasswordTest();
registerTest();
loginTest();
});
}
and finally run the app using this.
flutter drive --target=test_driver/testAll.dart
flutter drive — target=test_driver/app.dart — driver=test_driver/app_test.dart
flutter drive — target=test_driver/app.dart — driver=test_driver/home_test.dart
– Royroyal