本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
對 AWS Device Farm 中的 Appium Java TestNG 測試進行故障診斷
下列主題會列出在上傳 Appium Java TestNG 測試期間出現的錯誤訊息,並建議解決每個錯誤的解決方法。
上傳錯誤
當您上傳 Appium Java TestNG 測試時,可能會發生下列錯誤。
APPIUM_JAVA_TESTNG_TEST_PACKAGE_UNZIP_FAILED
如果您看到下列訊息,請依照以下步驟修復問題。
警告
無法開啟您的測試 ZIP 檔。請確認檔案是否有效,然後再試一次。
請確認您可以正確解壓縮測試套件。在下列範例中,套件的名稱是 zip-with-dependencies.zip。
-
將您的測試套件複製到工作目錄,然後執行下列命令:
$ unzip zip-with-dependencies.zip -
成功解壓縮套件後,您可以透過執行下列命令找到樹狀結構的工作目錄:
$ 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_JAVA_TESTNG_TEST_PACKAGE_DEPENDENCY_DIR_MISSING
如果您看到下列訊息,請依照以下步驟修復問題。
警告
在測試套件找不到 dependency-jars 目錄。請解壓縮您的測試套件,確認 dependency-jars 目錄位於套件中,然後再試一次。
在下列範例中,套件的名稱是 zip-with-dependencies.zip。
-
將您的測試套件複製到工作目錄,然後執行下列命令:
$ unzip zip-with-dependencies.zip -
成功解壓縮套件後,您可以透過執行下列命令找到樹狀結構的工作目錄:
$ 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_JAVA_TESTNG_TEST_PACKAGE_JAR_MISSING_IN_DEPENDENCY_DIR
如果您看到下列訊息,請依照以下步驟修復問題。
警告
在相依性 jar 目錄樹狀結構中找不到 JAR 檔案。請解壓縮您的測試套件,開啟相依性 jar 目錄,確認目錄中至少有一個 JAR 檔案,然後再試一次。
在下列範例中,套件的名稱是 zip-with-dependencies.zip。
-
將您的測試套件複製到工作目錄,然後執行下列命令:
$ unzip zip-with-dependencies.zip -
成功解壓縮套件後,您可以透過執行下列命令找到樹狀結構的工作目錄:
$ 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_JAVA_TESTNG_TEST_PACKAGE_TESTS_JAR_FILE_MISSING
如果您看到下列訊息,請依照以下步驟修復問題。
警告
在您的測試套件中找不到 *-tests.jar 檔案。請解壓縮您的測試套件,確認至少一個 *-tests.jar 檔案位於套件中,然後再試一次。
在下列範例中,套件的名稱是 zip-with-dependencies.zip。
-
將您的測試套件複製到工作目錄,然後執行下列命令:
$ unzip zip-with-dependencies.zip -
成功解壓縮套件後,您可以透過執行下列命令找到樹狀結構的工作目錄:
$ 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_JAVA_TESTNG_TEST_PACKAGE_CLASS_FILE_MISSING_IN_TESTS_JAR
如果您看到下列訊息,請依照以下步驟修復問題。
警告
在測試 JAR 檔案中找不到類別檔案。請解壓縮您的測試套件,反編譯測試 JAR 檔案,確認 JAR 檔案中至少有一個類別檔案,然後再試一次。
在下列範例中,套件的名稱是 zip-with-dependencies.zip。
-
將您的測試套件複製到工作目錄,然後執行下列命令:
$ unzip zip-with-dependencies.zip -
成功解壓縮套件後,您可以透過執行下列命令找到樹狀結構的工作目錄:
$ 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 -
若要從 JAR 檔案中擷取檔案,您可執行以下命令:
$ jar xf acme-android-appium-1.0-SNAPSHOT-tests.jar -
成功擷取檔案後,請執行下列命令:
$ 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 測試。
測試洞見
當您選擇加入測試洞見時,Device Farm 會為您的執行及其下的每個任務產生摘要報告。如果服務無法產生報告,洞察報告狀態為 SKIPPED或 ERRORED,報告訊息會說明原因。產生 Appium Java TestNG 測試的洞見時,可能會發生下列訊息。
任務未執行至完成
Unable to generate test insights because the job was
status.
任務以非成功狀態結束 (狀態為 STOPPED、 或 SKIPPED)ERRORED,因此沒有摘要結果。結束為失敗狀態的執行仍會收到洞見。
若要解決此問題,請調查任務未執行到完成的原因。在許多情況下,任務本身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。