如何 运行 在模拟器中使用 fastlane 进行仪器测试?
How to run instrumentation tests using fastlane in emulator?
我面临的问题是我无法 运行 使用 FastLane 进行浓缩咖啡测试,我想做的是 运行 通过 Fastlane 插件在模拟器中进行测试
我用的是fastlane的automated_test_emulator_run插件,我按照这篇文章的步骤https://medium.com/pink-room-club/android-continuous-integration-using-fastlane-and-circleci-2-0-part-i-7204e2e7b8b
现在,我只想 运行 在本地进行测试,所以当我 运行 以下
捆绑执行快车道instrumentation_tests
失败并出现错误:没有这样的文件或目录 - /tools/bin/avdmanager
这是我在快车道的车道
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
#for increment the version code
android_get_version_code(
gradle_file: "app/build.gradle" # optional
)
android_set_version_code(
gradle_file: "app/build.gradle" # optional
)
desc "Run instrumentation tests"
lane :instrumentation_tests do
automated_test_emulator_run(
AVD_setup_path: "fastlane/AVD_setup.json",
AVD_recreate_new: false,
AVD_clean_after: false,
gradle_task: "connectedDebugAndroidTest")
end
end
这是我的 AVD_setup.json
{
"avd_list": [
{
"avd_name": "Pixel_2_API_Test",
"create_avd_package": "system-images;android-28;google_apis_playstore;x86",
"create_avd_device": "Pixel 2",
"create_avd_tag": "google_apis_playstore",
"create_avd_abi": "x86",
"create_avd_additional_options": "",
"create_avd_hardware_config_filepath": "",
"launch_avd_port": "",
"launch_avd_snapshot_filepath": "",
"launch_avd_launch_binary_name": "emulator",
"launch_avd_additional_options": "-skin 1080x1920 -gpu on"
}
]
}
这是输出的一部分和我得到的错误
[13:34:31]: Driving the lane 'android instrumentation_tests'
[13:34:31]: -----------------------------------------
[13:34:31]: --- Step: automated_test_emulator_run ---
[13:34:31]: -----------------------------------------
[13:34:31]: The automated_test_emulator_run plugin is working!
[13:34:31]: Preparing commands for Android ADB
[13:34:31]: Preparing parameters and commands for emulator:
Pixel_2_API_Test
[13:34:31]: Configuring environment in order to launch emulators:
[13:34:31]: Getting avaliable AVDs
[13:34:31]: $ /tools/bin/avdmanager list avd
+--------------------------+-------------------------------+
| Lane Context |
+--------------------------+-------------------------------+
| DEFAULT_PLATFORM | android |
| ANDROID_VERSION_CODE | 38 |
| ANDROID_NEW_VERSION_CODE | 39 |
| PLATFORM_NAME | android |
| LANE_NAME | android instrumentation_tests |
+--------------------------+-------------------------------+
[13:34:31]: No such file or directory - /tools/bin/avdmanager
+------+-----------------------------+-------------+
| fastlane summary |
+------+-----------------------------+-------------+
| Step | Action | Time (in s) |
+------+-----------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | android_get_version_code | 0 |
| 3 | android_set_version_code | 0 |
| 4 | prompt | 4 |
| | automated_test_emulator_run | 0 |
+------+-----------------------------+-------------+
[13:34:31]: fastlane finished with errors
[13:34:31]: Error accessing file, this might be due to fastlane's
directory handling
[13:34:31]: Check out
https://docs.fastlane.tools/advanced/#directory-behavior for more
details
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:199:in `spawn': No such file or directory - /tools/bin/avdmanager (Errno::ENOENT)
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:199:in `popen_run'
from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:190:in popen2e'
from /Library/Ruby/Gems/2.3.0/gems/fastlane->2.120.0/fastlane/lib/fastlane/helper/sh_helper.rb:54:in
sh_control_output'
from >/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/forwardable.rb:202:in sh'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-plugin-automated_test_emulator_run-1.6.0/lib/fastlane/plugin/automated_test_emulator_run/actions/automated_test_emulator_run_action.rb:48:in
run'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:256:in block (2 levels) in execute_action'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-
2.120.0/fastlane/lib/fastlane/actions/actions_helper.rb:50:in
execute_action'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:235:in block in execute_action'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:227:in
chdir'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:227:in execute_action'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:157:in
trigger_action_by_name'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/fast_file.rb:154:in method_missing'
from Fastfile:26:in
block (2 levels) in parsing_binding'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/lane.rb:33:in call'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:49:in
block in execute'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:45:in chdir'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:45:in
execute'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/lane_manager.rb:56:in cruise_lane'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/command_line_handler.rb:36:in
handle'
from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
不知道该怎么办?我错过了什么?错误提到这可能是由于 fastlane 的目录处理,所以我去了 link 但不知道该怎么做?!我正在使用更新的 fastlane 和插件,请帮助我并提前致谢
忽略关于目录处理的标准快速通道错误消息。
这是你正在使用的插件(https://github.com/AzimoLabs/fastlane-plugin-automated-test-emulator-run 来自我的谷歌搜索 - 你实际上没有提供更多相关信息),command/program 它试图使用(/tools/bin/avdmanager list avd
) 和本地 Android 安装。
您应该查明您的本地 Android 是否真的有 avdmanager
命令及其所在的位置,以及 list avd
是否可以使用它。然后找出为什么插件没有从正确的位置使用它。
预感:插件可能正在使用 ENV 变量 ANDROID_HOME
或您系统上为空的类似变量。
我面临的问题是我无法 运行 使用 FastLane 进行浓缩咖啡测试,我想做的是 运行 通过 Fastlane 插件在模拟器中进行测试
我用的是fastlane的automated_test_emulator_run插件,我按照这篇文章的步骤https://medium.com/pink-room-club/android-continuous-integration-using-fastlane-and-circleci-2-0-part-i-7204e2e7b8b
现在,我只想 运行 在本地进行测试,所以当我 运行 以下
捆绑执行快车道instrumentation_tests
失败并出现错误:没有这样的文件或目录 - /tools/bin/avdmanager
这是我在快车道的车道
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
#for increment the version code
android_get_version_code(
gradle_file: "app/build.gradle" # optional
)
android_set_version_code(
gradle_file: "app/build.gradle" # optional
)
desc "Run instrumentation tests"
lane :instrumentation_tests do
automated_test_emulator_run(
AVD_setup_path: "fastlane/AVD_setup.json",
AVD_recreate_new: false,
AVD_clean_after: false,
gradle_task: "connectedDebugAndroidTest")
end
end
这是我的 AVD_setup.json
{
"avd_list": [
{
"avd_name": "Pixel_2_API_Test",
"create_avd_package": "system-images;android-28;google_apis_playstore;x86",
"create_avd_device": "Pixel 2",
"create_avd_tag": "google_apis_playstore",
"create_avd_abi": "x86",
"create_avd_additional_options": "",
"create_avd_hardware_config_filepath": "",
"launch_avd_port": "",
"launch_avd_snapshot_filepath": "",
"launch_avd_launch_binary_name": "emulator",
"launch_avd_additional_options": "-skin 1080x1920 -gpu on"
}
]
}
这是输出的一部分和我得到的错误
[13:34:31]: Driving the lane 'android instrumentation_tests'
[13:34:31]: -----------------------------------------
[13:34:31]: --- Step: automated_test_emulator_run ---
[13:34:31]: -----------------------------------------
[13:34:31]: The automated_test_emulator_run plugin is working!
[13:34:31]: Preparing commands for Android ADB
[13:34:31]: Preparing parameters and commands for emulator:
Pixel_2_API_Test
[13:34:31]: Configuring environment in order to launch emulators:
[13:34:31]: Getting avaliable AVDs
[13:34:31]: $ /tools/bin/avdmanager list avd
+--------------------------+-------------------------------+
| Lane Context |
+--------------------------+-------------------------------+
| DEFAULT_PLATFORM | android |
| ANDROID_VERSION_CODE | 38 |
| ANDROID_NEW_VERSION_CODE | 39 |
| PLATFORM_NAME | android |
| LANE_NAME | android instrumentation_tests |
+--------------------------+-------------------------------+
[13:34:31]: No such file or directory - /tools/bin/avdmanager
+------+-----------------------------+-------------+
| fastlane summary |
+------+-----------------------------+-------------+
| Step | Action | Time (in s) |
+------+-----------------------------+-------------+
| 1 | default_platform | 0 |
| 2 | android_get_version_code | 0 |
| 3 | android_set_version_code | 0 |
| 4 | prompt | 4 |
| | automated_test_emulator_run | 0 |
+------+-----------------------------+-------------+
[13:34:31]: fastlane finished with errors
[13:34:31]: Error accessing file, this might be due to fastlane's
directory handling
[13:34:31]: Check out
https://docs.fastlane.tools/advanced/#directory-behavior for more
details
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:199:in `spawn': No such file or directory - /tools/bin/avdmanager (Errno::ENOENT) from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:199:in `popen_run' from
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/open3.rb:190:in
popen2e' from /Library/Ruby/Gems/2.3.0/gems/fastlane->2.120.0/fastlane/lib/fastlane/helper/sh_helper.rb:54:in
sh_control_output' from >/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/forwardable.rb:202:insh' from /Library/Ruby/Gems/2.3.0/gems/fastlane-plugin-automated_test_emulator_run-1.6.0/lib/fastlane/plugin/automated_test_emulator_run/actions/automated_test_emulator_run_action.rb:48:in
run' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:256:inblock (2 levels) in execute_action' from /Library/Ruby/Gems/2.3.0/gems/fastlane- 2.120.0/fastlane/lib/fastlane/actions/actions_helper.rb:50:in
execute_action' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:235:inblock in execute_action' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:227:in
chdir' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:227:inexecute_action' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:157:in
trigger_action_by_name' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/fast_file.rb:154:inmethod_missing' from Fastfile:26:in
block (2 levels) in parsing_binding' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/lane.rb:33:incall' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:49:in
block in execute' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:45:inchdir' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/runner.rb:45:in
execute' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/lane_manager.rb:56:incruise_lane' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/command_line_handler.rb:36:in
handle' from /Library/Ruby/Gems/2.3.0/gems/fastlane-2.120.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
不知道该怎么办?我错过了什么?错误提到这可能是由于 fastlane 的目录处理,所以我去了 link 但不知道该怎么做?!我正在使用更新的 fastlane 和插件,请帮助我并提前致谢
忽略关于目录处理的标准快速通道错误消息。
这是你正在使用的插件(https://github.com/AzimoLabs/fastlane-plugin-automated-test-emulator-run 来自我的谷歌搜索 - 你实际上没有提供更多相关信息),command/program 它试图使用(/tools/bin/avdmanager list avd
) 和本地 Android 安装。
您应该查明您的本地 Android 是否真的有 avdmanager
命令及其所在的位置,以及 list avd
是否可以使用它。然后找出为什么插件没有从正确的位置使用它。
预感:插件可能正在使用 ENV 变量 ANDROID_HOME
或您系统上为空的类似变量。