我们如何在 AWS 设备群设备上连续运行 Appium 测试脚本?

问题描述

在我的一个项目中,我们需要在 AWS 设备群的多台设备上运行 Appium 测试脚本。这与 AWS 设备群中的正常测试用例略有不同。

我们如何在 AWS 设备群设备上持续运行 Appium 测试脚本? (在 AWS 设备群中至少达到 150 分钟的限制)?测试脚本会检查设备上是否有预安装的应用程序,并按照测试脚本中的指定进行测试。

测试脚本一旦被触发,应该运行很长时间,做脚本中提到的测试吗?通常,测试脚本会执行任务并提供输出,然后退出。但在这种情况下,我们需要测试脚本持续运行并执行测试。

解决方法

感谢您的联系。在 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 与我联系。

谢谢, 乔恩