

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

# 在 AWS Device Farm 中对 Appium Java JUnit 测试进行故障排除
<a name="troubleshooting-appium-java-junit"></a>

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

**注意**  
以下说明基于 Linux x86\_64 和 Mac。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_UNZIP\_FAILED
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_UNZIP_FAILED"></a>

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

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

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ 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
   ```

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_DEPENDENCY\_DIR\_MISSING
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_DEPENDENCY_DIR_MISSING"></a>

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

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

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ 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
   ```

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_JAR\_MISSING\_IN\_DEPENDENCY\_DIR
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_JAR_MISSING_IN_DEPENDENCY_DIR"></a>

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

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

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ tree .
   ```

   如果 Appium Java JUnit 程序包有效，您将在 {{dependency-jars}} 目录中至少找到一个 {{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}}
   ```

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_TESTS\_JAR\_FILE\_MISSING
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_TESTS_JAR_FILE_MISSING"></a>

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

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

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ 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
   ```

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_CLASS\_FILE\_MISSING\_IN\_TESTS\_JAR
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR"></a>

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

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

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ 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
   ```

1. 成功提取文件后，您应通过运行以下命令在工作目录树中至少找到一个类：

   ```
   $ 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
   ```

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_JUNIT\_VERSION\_VALUE\_UNKNOWN
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_JUNIT_VERSION_VALUE_UNKNOWN"></a>

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

**警告**  
我们无法找到 JUnit 版本值。请解压缩您的测试程序包，打开 dependency-jars 目录，并验证 JUnit JAR 文件在该目录中，然后重试。

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   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)
   |— 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)
       |— {{junit-4.10.jar}}
       |— 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 Java JUnit 程序包有效，您将找到类似于我们的示例中的 jar 文件 {{junit-4.10.jar}} 的 JUnit 依赖项文件。名称应该包括关键字 {{junit}} 和其版本号，在此示例中为 4.10。

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。

## APPIUM\_JAVA\_JUNIT\_TEST\_PACKAGE\_INVALID\_JUNIT\_VERSION
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_INVALID_JUNIT_VERSION"></a>

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

**警告**  
我们发现 JUnit 版本低于我们支持的最低版本 4.10。请更改 JUnit 版本，然后重试。

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

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

   ```
   $ unzip zip-with-dependencies.zip
   ```

1. 成功解压缩程序包后，您可以通过运行以下命令找到工作目录树结构：

   ```
   $ tree .
   ```

   您应找到 JUnit 依赖项文件（例如我们的示例中的 {{junit-4.10.jar}}）及其版本号（在我们的示例中为 4.10）：

   ```
   .
   |— 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)
         |— {{junit-4.10.jar}}
         |— com.some-dependency.bar-4.1.jar
         |— com.another-dependency.thing-1.0.jar
         |— joda-time-2.7.jar
         `— log4j-1.2.14.jar
   ```
**注意**  
如果测试程序包中指定的 JUnit 版本低于我们支持的最低版本 4.10，您的测试可能无法正确执行。

   有关更多信息，请参阅 [在 Device Farm 中自动运行 Appium 测试将 Appium 测试与 Device Farm 集成](test-types-appium.md)。