'How to specify build variant while running integration test?

I need to run my app with build variants config. Like this

flutter run --flavor dev

I've added some integration_tests, for running those I tried to use this command

flutter test integration_test/login_test.dart 

How can I specify my build variants here while running tests?



Solution 1:[1]

I recently migrated my integration_test to the "new version" with the next dependencies:

dev_dependencies:
   integration_test:
      sdk: flutter
   flutter_test:
    sdk: flutter

It was very frustrating to have flavours enabled but not be able to run the integration test as the oficial documentation says (by using the command:

flutter test test/counter_test.dart

The only way i found to "run" the test with the --flavor thing was by running:

flutter run --flavor production integration_test/app_test.dart

Solution 2:[2]

Unfortunately, the flutter test does not support the flavor(build variant).

for this flutter, the driver is used, which allow us to mention flavor

flutter drive --driver=test_driver/driver.dart --target=integration_test/sample.dart --flavor dev

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Jitesh Mohite