我已經使用Cucumber-JVM爲Android成功集成了Robotium。
有關用於Cucumber-JVM和安裝的官方cucumber-android
模塊的信息,have a look here。您還可以在這裏找到有關Cucumber-JVM的API文檔和示例:http://cukes.info/platforms.html。
在您的應用程序的測試模塊中,只需將Robotium Solo jar文件作爲依賴項(範圍:編譯)添加即可。
我的一個測試類的看起來是這樣的:
public class CucumberSteps extends ActivityInstrumentationTestCase2<YourActivity> {
private Solo solo;
public CucumberSteps() {
super(YourActivity.class);
}
@Override
protected void setUp() throws Exception {
super.setUp();
}
@Before
public void before() {
solo = new Solo(getInstrumentation(), getActivity());
}
@After
public void after() throws Throwable {
//clean up
solo.finalize();
}
@Override
protected void tearDown() throws Exception {
solo.finishOpenedActivities();
super.tearDown();
}
@Given("^step_given_description$")
public void step_given_description() throws Throwable {
final View testView = solo.getView(R.id.testView);
solo.waitForView(testView);
solo.clickOnView(testView);
// and so on
}
}
我希望這是足夠的信息,任何人都可以上手。當問這個問題時,cucumber-android還沒有存在。請記住,GUI測試通常有點不穩定!我設法在本地獲得一組穩定的測試,但例如在詹金斯,通常一些測試失敗的原因不明。
你能給我比多一點點信息它們以何種方式不穩定?他們崩潰?他們失敗了很多?請提供更多信息,我會盡力幫助。作爲一個便箋,如果你要這樣,我會推薦看看https://github.com/calabash-driver/calabash-driver –