View a markdown version of this page

在 AWS Device Farm 中对 Appium Java TestNG 测试进行故障排除 - AWS Device Farm

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

在 AWS Device Farm 中对 Appium Java TestNG 测试进行故障排除

以下主题列出了在上传 Appium Java TestNG 测试期间出现的错误消息并推荐了解决方法来解决每个错误。

上传错误

当你上传 Appium Java TestNG 测试时,可能会出现以下错误。

APPIUM_JAVA_TESTNG_TEST_PACKAGE_UNZIP_FAILED

如果您看到以下消息,请执行以下步骤来修复此问题。

警告

我们无法打开您的测试 ZIP 文件。请验证文件是否有效,然后重试。

确保您可以解压测试程序包,而不会出现错误。在以下示例中,程序包的名称为 zip-with-dependencies.zip

  1. 将您的测试程序包复制到工作目录,然后运行以下命令:

    $ unzip zip-with-dependencies.zip
  2. 成功解压缩程序包后,您可以通过运行以下命令找到工作目录树结构:

    $ tree .

    有效的 Appium Java JUnit 程序包应生成类似以下内容的输出:

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar

    有关更多信息,请参阅 在设备农场中自动运行 Appium 测试

APPIUM_JAVA_TESTNG_TEST_PACKAGE_DEPENDENCY_DIR_MISSING

如果您看到以下消息,请执行以下步骤来修复此问题。

警告

我们无法在您的测试程序包中找到 dependency-jars 目录。请解压缩您的测试程序包,验证 dependency-jars 目录位于该程序包中,然后重试。

在以下示例中,程序包的名称为 zip-with-dependencies.zip

  1. 将您的测试程序包复制到工作目录,然后运行以下命令:

    $ unzip zip-with-dependencies.zip
  2. 成功解压缩程序包后,您可以通过运行以下命令找到工作目录树结构:

    $ tree .

    如果 Appium Java JUnit 包有效,则可以在工作dependency-jars目录中找到该目录。

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar

    有关更多信息,请参阅 在设备农场中自动运行 Appium 测试

APPIUM_JAVA_TESTNG_TEST_PACKAGE_JAR_MISSING_IN_DEPENDENCY_DIR

如果您看到以下消息,请执行以下步骤来修复此问题。

警告

我们无法在 dependency-jars 目录树中找到 JAR 文件。请解压缩您的测试程序包,打开 dependency-jars 目录,并验证至少有一个 JAR 文件在该目录中,然后重试。

在以下示例中,程序包的名称为 zip-with-dependencies.zip

  1. 将您的测试程序包复制到工作目录,然后运行以下命令:

    $ unzip zip-with-dependencies.zip
  2. 成功解压缩程序包后,您可以通过运行以下命令找到工作目录树结构:

    $ tree .

    如果 Appium Java JUnit 包有效,您将在该目录中找到至少一个jar文件。dependency-jars

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar

    有关更多信息,请参阅 在设备农场中自动运行 Appium 测试

APPIUM_JAVA_TESTNG_TEST_PACKAGE_TESTS_JAR_FILE_MISSING

如果您看到以下消息,请执行以下步骤来修复此问题。

警告

我们无法在您的测试程序包中找到 *-tests.jar 文件。请解压缩您的测试程序包,验证至少有一个 *-tests.jar 文件位于该程序包中,然后重试。

在以下示例中,程序包的名称为 zip-with-dependencies.zip

  1. 将您的测试程序包复制到工作目录,然后运行以下命令:

    $ unzip zip-with-dependencies.zip
  2. 成功解压缩程序包后,您可以通过运行以下命令找到工作目录树结构:

    $ tree .

    如果 Appium Java JUnit 包有效,您将找到至少一个jar文件,如我们的示例acme-android-appium-1.0-SNAPSHOT-tests.jar所示。该文件的名称可能不同,但应以结尾–tests.jar

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar

    有关更多信息,请参阅 在设备农场中自动运行 Appium 测试

APPIUM_JAVA_TESTNG_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR

如果您看到以下消息,请执行以下步骤来修复此问题。

警告

我们无法在测试 JAR 文件中找到类文件。请解压缩您的测试程序包,解压测试 JAR 文件,并验证至少有一个类文件在该 JAR 文件中,然后重试。

在以下示例中,程序包的名称为 zip-with-dependencies.zip

  1. 将您的测试程序包复制到工作目录,然后运行以下命令:

    $ unzip zip-with-dependencies.zip
  2. 成功解压缩程序包后,您可以通过运行以下命令找到工作目录树结构:

    $ tree .

    你应该找到至少一个 jar 文件,就像acme-android-appium-1.0-SNAPSHOT-tests.jar我们的示例一样。该文件的名称可能不同,但应以结尾–tests.jar

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar
  3. 要从 jar 文件中提取文件,可以运行以下命令:

    $ jar xf acme-android-appium-1.0-SNAPSHOT-tests.jar
  4. 在您成功提取文件后,运行以下命令:

    $ tree .

    您应在工作目录树中至少找到一个类:

    . |— acme-android-appium-1.0-SNAPSHOT.jar (this is the JAR containing everything built from the ./src/main directory) |— acme-android-appium-1.0-SNAPSHOT-tests.jar (this is the JAR containing everything built from the ./src/test directory) |- one-class-file.class |- folder | `— another-class-file.class |— zip-with-dependencies.zip (this .zip file contains all of the items) `— dependency-jars (this is the directory that contains all of your dependencies, built as JAR files) |— com.some-dependency.bar-4.1.jar |— com.another-dependency.thing-1.0.jar |— joda-time-2.7.jar `— log4j-1.2.14.jar

    有关更多信息,请参阅 在设备农场中自动运行 Appium 测试

测试见解

当您选择使用测试见解时,Device Farm 会为您的运行及其下的每项任务生成一份汇总报告。如果服务无法生成报告,则见解报告的状态为SKIPPEDERRORED,报告消息将解释原因。在为Appium Java TestNG测试生成见解时,可能会出现以下消息。

任务没有运行到完成

Unable to generate test insights because the job was status.

任务以非成功状态(其中 statusSTOPPEDERROREDSKIPPED)结束,因此没有结果可供汇总。以失败状态结束的运行仍能获得见解。

要解决此问题,请调查任务未完成的原因。在许多情况下,工作message领域本身可以解释任务未完成的原因。

结果不包含测试用例

Test insights could not be generated. The testng-results.xml file was parsed successfully but contained no test cases.

结果工件已成功解析,但包含零个测试用例。

要解决此问题,请验证您的测试套件是否包含至少一个测试用例,并且结果是否正确存储在$DEVICEFARM_LOG_DIR

测试输出超过了支持的最大大小

Unable to generate test insights: test output "testng-results.xml" exceeds the maximum supported size of 1GB.

testng-results.xml 大于 1 GB。

要解决此问题,请通过修剪日志或附件,将 testng-results.xml 的大小减少到 1 GB 以下。

找不到 testng-results.xml 文件

Unable to generate test insights. The test results file (testng-results.xml) was not found.

未找到任何testng-results.xml文件(也未找到带有 TestNG 根签名的 XML 条目)。

要解决此问题,请将您的框架配置为将 TestNG XML 发送到构件目录 () $DEVICEFARM_LOG_DIR

无法处理 testng-results.xml 文件

Test insights could not be generated because of an error while processing testng-results.xml.

XML 文件格式错误或无法解析。

要解决此问题,请确保该文件是标准 TestNG 报告格式正确的 XML。