How can you run multiple integration tests with a single config file in Flutter?

· 3 min read
run multiple integration tests with a single config file in Flutter
run multiple integration tests with a single config file in Flutter

Unit tests and widget tests are a great way of testing classes, functions, and widgets in isolation. However, it is just as important to test that all these moving parts work together as a whole and when dealing with complex apps with many screens, it is hard and error-prone to manually test multiple user journeys. So let us get to know, how can you run multiple integration tests with a single config file in Flutter.

How can you run multiple integration tests with a single config file in Flutter?

You can have one main test file like this:

flutter drive --target=test_driver/app_test.dart

Now in that, you can call test groups as functions like below :

void main() 
{
  test1();
}
void test1() 
{
  group('test 1', () {});
}

So you can execute all the cases mentioned in main( ) in one command.

Screenshot:

run multiple integration tests with one single config file in Flutter
screenshot

You can also create a single test file and call all main methods from within:

import './first_test.dart' as first;
import './second_test.dart' as second;

void main() {
  first.main();
  second.main();
}

Now, Run the driver on the single test file:

flutter drive --driver=test/integration/integration_test_driver.dart --target=test/integration/run_all_test.dart

Your config file is your target and your test file is your driver in flutter jargon. Your target is always c but you have the two drivers login_test.dart and login_warning.dart.

You can specify the target as well as the driver with the flutter drive command.

So in order to run both drivers, simply execute the following commands

flutter drive --target=test_driver/login.dart --driver=test_driver/login_test.dart
flutter drive --target=test_driver/login.dart --driver=test_driver/login_warning.dart

This executes first the login_test.dart and then the

login_warning.dart driver.

make executable:
$chmod a+rx integration_tests.sh
run it:
$./integration_tests.sh

Conclusion:

So in this article, We have been through how can you run multiple integration tests with a single config file in Flutter.

Keep Learning !!! Keep Fluttering !!!

Still, need Support for Flutter Development? Please let us know.

FlutterAgency.com is our portal Platform dedicated to Flutter Technology and Flutter Developers. The portal is full of cool resources from Flutter like Flutter Widget GuideFlutter ProjectsCode libs and etc.

FlutterAgency.com is one of the most popular online portals dedicated to Flutter Technology and daily thousands of unique visitors come to this portal to enhance their knowledge of Flutter.

Leave a Reply