我已经使用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 –