这是采取截图,当一个场景中使用Robotium和黄瓜失败的最佳方式?正确的方式,采取截图与Robotium和黄瓜
我曾尝试(没有成功,因为它不执行的runTest方法)与此:
import cucumber.api.CucumberOptions;
import cucumber.api.java.After;
import cucumber.api.java.Before;
@CucumberOptions(features = "features", tags = {"[email protected]"})
public class CustomInstrumentationTestCase extends ActivityInstrumentationTestCase2<LaunchActivity> {
protected Solo solo;
public CustomInstrumentationTestCase() {
super(LaunchActivity.class);
}
@Before
public void before() throws Exception {
//...
}
@After
public void after() throws Exception {
//...
}
@Override
protected void runTest() throws Throwable {
try {
super.runTest();
} catch (Throwable t) {
final String testCaseName = String.format("%s.%s", getClass().getName(), getName());
solo.takeScreenshot(testCaseName);
Log.w("Boom! Screenshot!", String.format("Captured screenshot for failed test: %s", testCaseName));
throw t;
}
}
}
而且我已经在清单中设置的权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
你有设置在被测应用程序的AndroidManifest.xml中的许可标签? – Renas
将测试方法的名称更改为以测试开始。所以在你的情况下,它可能是testRun()。 – Renas
“所以你的情况可能是testRun()”nope--他的代码看起来很好! testRun方法被使用,因为断言错误和报告失败被抛出。 – PKAP