這是採取截圖,當一個場景中使用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