【问题标题】:Integration test not running with flavor集成测试不以风味运行
【发布时间】:2021-08-13 13:37:51
【问题描述】:

我正在使用 Flutter 应用程序运行集成测试。我也在 Flutter 中使用Flavors。问题是它给了我这个错误:

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. 我已将所有依赖项放入pubspec.yaml
  2. 创建了文档中提到的 3 个目录: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));
  });
}

然后在终端运行以下命令:

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

【问题讨论】:

    标签: flutter integration-testing


    【解决方案1】:

    因为您使用的是风味,所以您需要指定要运行您的应用的风味:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-12-31
      • 1970-01-01
      • 2011-02-02
      • 2013-06-29
      • 2015-09-05
      • 1970-01-01
      • 1970-01-01
      • 2014-12-05
      相关资源
      最近更新 更多