

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 對 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>

如果您看到下列訊息，請依照以下步驟修復問題。

**警告**  
在測試套件找不到相依性 jar 目錄。請解壓縮您的測試套件，確認相依性 jar 目錄位於套件中，然後再試一次。

在下列範例中，套件的名稱是 **zip-with-dependencies.zip**。

1. 將您的測試套件複製到工作目錄，然後執行下列命令：

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

1. 成功解壓縮套件後，您可以透過執行下列命令找到樹狀結構的工作目錄：

   ```
   $ tree .
   ```

   如果 Appium Java JUnit 套件是有效的，您可以在工作目錄中找到 {{相依性 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\_JAR\_MISSING\_IN\_DEPENDENCY\_DIR
<a name="APPIUM_JAVA_JUNIT_TEST_PACKAGE_JAR_MISSING_IN_DEPENDENCY_DIR"></a>

如果您看到下列訊息，請依照以下步驟修復問題。

**警告**  
在相依性 jar 目錄樹狀結構中找不到 JAR 檔案。請解壓縮您的測試套件，開啟相依性 jar 目錄，確認目錄中至少有一個 JAR 檔案，然後再試一次。

在下列範例中，套件的名稱是 **zip-with-dependencies.zip**。

1. 將您的測試套件複製到工作目錄，然後執行下列命令：

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

1. 成功解壓縮套件後，您可以透過執行下列命令找到樹狀結構的工作目錄：

   ```
   $ tree .
   ```

   如果 Appium Java JUnit 套件有效，您會在 dependency-{{jar}} s目錄中找到至少一個 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 版本值。請解壓縮您的測試套件，開啟相依性 jar 目錄，確認目錄中有 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 套件是有效的，您可以找到 JUnit 相依性檔案，類似於範例中的 {{junit-4.10.jar}} JAR 檔案。名稱應包含關鍵字 {{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)。