Khamidjon Khamidov
Khamidjon Khamidov

Reputation: 8899

Integration test not running with flavor

I am running integration tests with Flutter application. I am also using Flavors in Flutter. The problem is it is giving me this error:

Gradle build failed to produce an .apk file. It's likely that this file was generated under /home/khamidjon/Desktop/android_flutter_projects/my-project/build, but the tool couldn't find it.
  1. I have put all the dependencies inside pubspec.yaml.
  2. created 3 directories as docs mentioned: integration_test/, test_driver/, test/

test_driver/integration_test.dart:

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();

integration_test/main_functions_test.dart:

import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';

    
void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();

  testWidgets("failing test example", (WidgetTester tester) async {
    expect(2 + 2, equals(5));
  });
}

Then run following command in terminal:

  flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/main_functions_test.dart
 

Upvotes: 4

Views: 3298

Answers (2)

IvanPavliuk
IvanPavliuk

Reputation: 1790

This helped me to fix the same problem.

  1. Create new scheme in Xcode for running integration tests (in my case it named e2e):

enter image description here

  1. Add a configuration:

enter image description here

  1. Update Build Configuration of the added scheme:

enter image description here

  1. Specify the path to integration tests:

enter image description here

  1. The integration_test/app_test.dart should look like this:

enter image description here

  1. Run with the next command: flutter drive --driver=test_driver/integration_test.dart --target=integration_test/app_test.dart --flavor e2e

Upvotes: 2

Khamidjon Khamidov
Khamidjon Khamidov

Reputation: 8899

Because you are using flavors, you need to specify which flavor you want to run your app:

flutter drive \
  --driver=test_driver/integration_test.dart \
  --target=integration_test/main_functions_test.dart --flavor development

Upvotes: 2

Related Questions