【问题标题】:How can we run the Appium test script continuously on the AWS device farm devices?我们如何在 AWS 设备场设备上连续运行 Appium 测试脚本?
【发布时间】:2021-07-15 22:50:36
【问题描述】:
在我的一个项目中,我们需要在 AWS 设备场的多台设备上运行 Appium 测试脚本。这与 AWS 设备场上的正常测试用例略有不同。
我们如何在 AWS 设备场设备上连续运行 Appium 测试脚本? (AWS 设备场中至少有 150 分钟的限制)?测试脚本会检查设备上的预安装应用程序,并按照测试脚本中的说明进行测试。
一旦触发测试脚本,它应该运行很长时间并执行脚本中提到的测试?通常,测试脚本会执行任务并提供输出,然后退出。但是在这种情况下,我们需要测试脚本连续运行并执行测试。
【问题讨论】:
标签:
amazon-web-services
appium
devops
aws-device-farm
【解决方案1】:
感谢您与我们联系。在 AWS Device Farm 中,我们提供了一种称为“自定义环境模式”的执行模式,它允许您通过 YAML 规范文件定义如何使用真实的 shell 语法执行测试。
在下面的示例中,我采用我们的 Appium TestNG 默认 YAML 文件的“测试”阶段,并将其更改为在循环中运行,并将您描述的要求转换为 shell 代码:
# The test phase includes commands that start your test suite execution.
test:
commands:
# max_duration should be a few minutes less than the Device Farm test timeout
# For example, for a 150 minute test, we will time out internally after 140 mins
- max_duration=8400
- test_start_time=$(date +%s)
- test_duration=0
- cd $DEVICEFARM_TEST_PACKAGE_PATH
- >-
while [ "$test_duration" -le "$max_duration" ];
do
java -Dappium.screenshots.dir=$DEVICEFARM_SCREENSHOT_PATH org.testng.TestNG -testjar *-tests.jar -d $DEVICEFARM_LOG_DIR/test-output -verbose 10;
test_duration=$(($(date +%s)-test_start_time));
done;
如果您在自定义 YAML 文件或一般执行体验方面需要更多帮助,请通过 simsjon@amazon.com 与我联系。
谢谢,
乔恩