【问题标题】:Having both JUnit and Cucumber tests in a single Android project在单个 Android 项目中同时进行 JUnit 和 Cucumber 测试
【发布时间】:2016-09-21 17:09:55
【问题描述】:

我希望将 Cucumber 测试引入我的 Android 应用程序。为此,我需要一个使用 CucumberInstrumentationCore 的自定义测试仪器运行程序,如 here 所述。

但是我已经有了由 JUnit 驱动的 Espresso 测试,因此我已经有了一个使用 AndroidJUnitTestRunner 的自定义测试仪器运行程序。

在我看来,自定义实现不能同时使用两者,因为每个测试活动的 onStart() 方法调用 finish()

看来我的选择是:

  • 复制CucumberInstrumentationCoreAndroidJUnitTestRunner 的源代码,并生成一个新的组合测试运行器,它可以执行两者的必要部分

或者……

  • 将 JUnit 测试放在 androidTest 文件夹中,并在 androidTest 旁边创建一个新的检测测试文件夹,其中仅包含 Cucumber 测试。这甚至可能吗?

我该如何继续,我是否错过了一种更优雅的方式?

【问题讨论】:

标签: android unit-testing junit cucumber


【解决方案1】:

我最终生成了一个组合 instrumentationTestRunner 似乎工作正常:

https://gist.github.com/dhoskins/98afa6976c87cb20328d42065c7292ee

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    • 2011-04-04
    • 2020-12-27
    • 2016-02-15
    • 1970-01-01
    • 2017-08-08
    相关资源
    最近更新 更多