测试 (AVD) 测试 - 失败:仪器 运行 由于 'java.io.IOException' 而失败
Tests on test(AVD) - failed: Instrumentation run failed due to 'java.io.IOException'
当 运行使用 Gradle 测试我的 Cucumber-jvm 时出现此错误 Android 模拟器.
完全相同的测试 运行 在设备上完美,但我需要在模拟器上 运行 它们才能在 Travis CI
上执行测试
调试错误:
Executing task ':app:connectedDebugAndroidTest' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/outputs/androidTest-results/connected) returned: true
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/outputs/code-coverage/connected) returned: true
Starting 0 tests on test(AVD) - 5.0.2
Tests on test(AVD) - 5.0.2 failed: Instrumentation run failed due to 'java.io.IOException'
com.android.builder.testing.ConnectedDevice > No tests found.[test(AVD) - 5.0.2] [31mFAILED [0m
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/reports/androidTests/connected) returned: true
:app:connectedDebugAndroidTest FAILED
:app:connectedDebugAndroidTest (Thread[main,5,main]) completed. Took 3 mins 13.635 secs.
FAILURE: Build failed with an exception.
执行和失败的完整日志:
https://s3.amazonaws.com/archive.travis-ci.org/jobs/81209650/log.txt
这是我创建的 CucumberTestCase.class 来配置 Cucumber 将执行哪些测试以及使用 @CucumberOptions:
import cucumber.api.CucumberOptions;
/**
* This class configures the Cucumber test framework and Java glue code
*/
@CucumberOptions(features = "features", // Test scenarios
glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
format = {"pretty", // Cucumber report formats and location to store them in phone
"html:/mnt/sdcard/cucumber-reports/html-report",
"json:/mnt/sdcard/cucumber-reports/cucumber.json",
"junit:/mnt/sdcard/cucumber-reports/cucumber.xml"
},
tags={"~@manual", "@login-scenarios"}
)
public class CucumberTestCase {
}
要启动的命令是:
./gradlew connectedAndroidTest -PdisablePreDex --stacktrace --info
问题'java.io.IOException'是因为Cucumber-jvm在format下无法写入@CucumberOptions中指示的位置.
在我的例子中,这是因为该路径存在于设备上但不存在于模拟器上,这就是它仅在模拟器上失败的原因。
解决办法是把路径改成html、json和junit 向设备和模拟器中可写 的路径报告。
我的初始路径 (/mnt/sdcard/cucumber-reports/html-report) 非常适合放置 html 报告并在执行完成后检索它。在设备和模拟器中都有效的路径是下面的例子,但是这个路径将在应用程序被删除后被删除 Gradle 测试执行:
@CucumberOptions(features = "features", // Test scenarios
glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
format = {"pretty", // Cucumber report formats and location to store them in phone
"html:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/html-report",
"json:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/cucumber.json",
"junit:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/cucumber.xml"
},
tags={"~@manual", "@login-scenarios"}
)
当 运行使用 Gradle 测试我的 Cucumber-jvm 时出现此错误 Android 模拟器.
完全相同的测试 运行 在设备上完美,但我需要在模拟器上 运行 它们才能在 Travis CI
上执行测试调试错误:
Executing task ':app:connectedDebugAndroidTest' (up-to-date check took 0.0 secs) due to:
Task has not declared any outputs.
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/outputs/androidTest-results/connected) returned: true
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/outputs/code-coverage/connected) returned: true
Starting 0 tests on test(AVD) - 5.0.2
Tests on test(AVD) - 5.0.2 failed: Instrumentation run failed due to 'java.io.IOException'
com.android.builder.testing.ConnectedDevice > No tests found.[test(AVD) - 5.0.2] [31mFAILED [0m
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
deleteDir(/home/travis/build/neoranga55/Experiment-CI/app/build/reports/androidTests/connected) returned: true
:app:connectedDebugAndroidTest FAILED
:app:connectedDebugAndroidTest (Thread[main,5,main]) completed. Took 3 mins 13.635 secs.
FAILURE: Build failed with an exception.
执行和失败的完整日志: https://s3.amazonaws.com/archive.travis-ci.org/jobs/81209650/log.txt
这是我创建的 CucumberTestCase.class 来配置 Cucumber 将执行哪些测试以及使用 @CucumberOptions:
import cucumber.api.CucumberOptions;
/**
* This class configures the Cucumber test framework and Java glue code
*/
@CucumberOptions(features = "features", // Test scenarios
glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
format = {"pretty", // Cucumber report formats and location to store them in phone
"html:/mnt/sdcard/cucumber-reports/html-report",
"json:/mnt/sdcard/cucumber-reports/cucumber.json",
"junit:/mnt/sdcard/cucumber-reports/cucumber.xml"
},
tags={"~@manual", "@login-scenarios"}
)
public class CucumberTestCase {
}
要启动的命令是:
./gradlew connectedAndroidTest -PdisablePreDex --stacktrace --info
问题'java.io.IOException'是因为Cucumber-jvm在format下无法写入@CucumberOptions中指示的位置.
在我的例子中,这是因为该路径存在于设备上但不存在于模拟器上,这就是它仅在模拟器上失败的原因。
解决办法是把路径改成html、json和junit 向设备和模拟器中可写 的路径报告。
我的初始路径 (/mnt/sdcard/cucumber-reports/html-report) 非常适合放置 html 报告并在执行完成后检索它。在设备和模拟器中都有效的路径是下面的例子,但是这个路径将在应用程序被删除后被删除 Gradle 测试执行:
@CucumberOptions(features = "features", // Test scenarios
glue = {"com.neoranga55.cleanguitestarchitecture.cucumber.steps"}, // Steps definitions
format = {"pretty", // Cucumber report formats and location to store them in phone
"html:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/html-report",
"json:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/cucumber.json",
"junit:/data/data/com.neoranga55.cleanguitestarchitecture/cucumber-reports/cucumber.xml"
},
tags={"~@manual", "@login-scenarios"}
)