首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Robotium BDD与黄瓜

Robotium BDD与黄瓜
EN

Stack Overflow用户
提问于 2013-01-11 22:29:57
回答 3查看 1.9K关注 0票数 1

我想知道你们是否知道如何使用Robotium进行BDD测试。

在我的研究中,Robotium使用不同的虚拟机(Dalvik),所以我不能作为Junit Test运行(只能使用Android Junit Test)。因此,我找到了一个可行的解决方案,将Robotium与Junit和RoboRemote https://github.com/groupon/robo-remote一起运行。但当我尝试与cucumber集成时,测试变得不稳定。

你们知道用Robotium做BDD测试的方法吗?

EN

回答 3

Stack Overflow用户

发布于 2013-11-13 05:50:56

我已经使用Cucumber-JVM for Android成功地集成了Robotium。

有关Cucumber-JVM的官方cucumber-android模块及其安装的信息,请参阅have a look here。您也可以在这里找到关于Cucumber-JVM的API文档和示例:http://cukes.info/platforms.html

在应用程序的测试模块中,只需添加Robotium Solo jar-file作为依赖项(范围:编译)。

我的一个测试类看起来像这样:

代码语言:javascript
复制
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中,通常一些测试会因为未知的原因而失败。

票数 2
EN

Stack Overflow用户

发布于 2014-02-16 22:09:36

我知道这是一个非常古老的问题,但是关于这个主题的文档非常有限,所以我将发布另一条信息。

这篇文章对我帮助很大:http://www.opencredo.com/2014/01/28/cucumber-android-vs-cucumber-appium/

我在这里也使用了文档(我知道它已经被弃用了,但主项目根本没有关于安卓的文档):https://github.com/mfellner/cucumber-android

我使用IntelliJ Bootstrap - http://www.androidbootstrap.com/ (主要是Maven13集成测试项目配置)中的bits让它与Android13社区版和Maven13一起工作。

希望能有所帮助。

票数 1
EN

Stack Overflow用户

发布于 2015-09-29 17:02:26

我用这个runner得到了cucumber-jvm和androidstudio的工作机器人:

代码语言:javascript
复制
   import android.os.Bundle;

   import cucumber.api.CucumberOptions; import
   cucumber.api.android.CucumberInstrumentation;


   @CucumberOptions(features = {"features"}, tags = {"@smoke",
   "~@pending", "~@manual", "~@reboot"})

   public class Instrumentation extends CucumberInstrumentation {

       private final CucumberInstrumentation instrumentationCore = new CucumberInstrumentation();

       @Override
       public void onCreate(final Bundle bundle) {
           super.onCreate(bundle);
           instrumentationCore.onCreate(bundle);
           start();
       }

       @Override
       public void onStart() {
           waitForIdleSync();
           instrumentationCore.start();
       }
   }
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14280233

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档