Robotium BDD 与黄瓜 [英] Robotium BDD with Cucumber
问题描述
我想知道你们是否知道如何使用 Robotium 进行 BDD 测试.
I want to know if you guys know how to make BDD tests with Robotium.
当我研究 Robotium 与不同的虚拟机 (Dalvik) 一起工作时,所以我无法作为 Junit 测试运行(仅使用 Android Junit 测试).所以我找到了一个可能的解决方案来运行 Robotium with Junit with RoboRemote https://github.com/groupon/robo-远程.但是当我尝试与黄瓜集成时,测试变得不稳定.
As I research Robotium works with a different Virtual Machine (Dalvik) so I cannot run as Junit Test (Only with Android Junit Test). So I found a possible solution to run Robotium with Junit with RoboRemote https://github.com/groupon/robo-remote. But when i tried to integrate with cucumber the tests became unstable.
所以你们知道一些使用 Robotium 进行 BDD 测试的方法吗?
So you guys know some way to make BDD tests using Robotium?
推荐答案
我已经使用 Cucumber-JVM for Android 成功集成了 Robotium.
I have successfully integrated Robotium using Cucumber-JVM for Android.
有关 Cucumber-JVM 的官方 cucumber-android
模块和安装的信息,看看这里.您还可以在此处找到有关 Cucumber-JVM 的 API 文档和示例:http://cukes.info/platforms.html.
For information about the now official cucumber-android
module for Cucumber-JVM and the installation, have a look here. You can also find API-documentation and examples about Cucumber-JVM here: http://cukes.info/platforms.html.
在应用的测试模块中,只需添加 Robotium Solo jar 文件作为依赖项(范围:编译).
In your test-module for your app, simply add the Robotium Solo jar-file as a dependency (Scope: Compile).
我的一个测试类看起来像这样:
One of my test-classes looks like this:
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 测试通常有些不稳定!我设法在本地获得了一组稳定的测试,但是例如在 Jenkins 中,通常一些测试会因为未知原因而失败.
I hope this is enough information for anyone to get started. When this question was asked, cucumber-android didn't exist yet. Keep in mind though, GUI tests are very often somewhat unstable! I managed to get a stable set of tests locally, but e.g. in Jenkins, usually some tests fail for unknown reasons.
这篇关于Robotium BDD 与黄瓜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!