简体   繁体   English

Codemagic:如何设置集成测试 Android 模拟器

[英]Codemagic: how do I set up integration tests Android Emulator

Here is how the default configuration for tests looks like:以下是测试的默认配置:

在此处输入图像描述

In Flutter Drive arguments we can see that there is a target defined在 Flutter 驱动 arguments 中我们可以看到定义了一个目标

drive --target=test_driver/main.dart驱动 --target=test_driver/main.dart

Flutter documentation on integration tests doesn't mention creating this file. Flutter 关于集成测试的文档没有提到创建这个文件。 So this folder with the respective file is missing in my project, which logically results into fail:因此,我的项目中缺少包含相应文件的此文件夹,这在逻辑上会导致失败:

Target file "test_driver/main.dart" not found.找不到目标文件“test_driver/main.dart”。

Here are the logs:以下是日志:

> flutter devices
3 connected devices:

Android SDK built for x86 (mobile) • emulator-5554 • android-x86    • Android 10 (API 29) (emulator)
macOS (desktop)                    • macos         • darwin-x64     • macOS 12.4 21F79 darwin-x64
Chrome (web)                       • chrome        • web-javascript • Google Chrome 103.0.5060.114
> flutter -d emulator-5554 drive --target=test_driver/main.dart
Target file "test_driver/main.dart" not found.

The documentation on how to write integration tests only mentions test_driver when testing web.关于如何编写集成测试的文档仅在测试 web 时提及test_driver

Apparently I am either missing stuff in my project or I need to configure codemagic workflow differently.显然我要么在我的项目中遗漏了一些东西,要么我需要以不同的方式配置 codemagic 工作流程。

There is a bit information here https://docs.codemagic.io/yaml-testing/testing/ for yaml configuration. https://docs.codemagic.io/yaml-testing/testing/这里有一点关于 yaml 配置的信息。 Should i switch to yaml config, or can it be done from CodeMagic UI?我应该切换到 yaml 配置,还是可以从 CodeMagic UI 完成?

UPDATE: After I have change the configuration as mentioned in the answers to this:更新:在我更改了答案中提到的配置后:

在此处输入图像描述

The logs are now:日志现在是:

Test file not found: > /Users/builder/clone/test_driver/app_test_test.dart未找到测试文件: > /Users/builder/clone/test_driver/app_test_test.dart

The recommended approach per Flutter documentation is to use:根据Flutter 文档推荐的方法是使用:

flutter test integration_test

Thus, in the arguments section in Codemagic, just add test integration_test .因此,在 Codemagic 的 arguments 部分中,只需添加test integration_test

test_driver/main.dart is just a placeholder. test_driver/main.dart只是一个占位符。 Flutter documentation covered this in step 3. Create the test files Flutter 文档在步骤3 中对此进行了介绍。创建测试文件

And in Codemagic you need to specify drive --target=integration_test/app_test.dart在 Codemagic 中,您需要指定drive --target=integration_test/app_test.dart

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM