同时使用InstrumentationTestRunner和AndroidJUnitRunner与Robotium和Espresso [英] Use both InstrumentationTestRunner and AndroidJUnitRunner with Robotium and Espresso
问题描述
我们将Robotium与android.test.InstrumentationTestRunner
一起使用进行测试.尽管如此,我们还是想用Robotium代替Espresso,但是我们仍然有一些疑问,因为我们有一台装有Jenkins的CI机器.
We're using Robotium with the android.test.InstrumentationTestRunner
for our tests. Nevertheless we want to replace Robotium for Espresso, but we still have some doubts about it, since we have a machine with Jenkins for the CI.
Espresso使用android.support.test.runner.AndroidJUnitRunner
,而Robotium使用上述(首先),我们希望能够同时使用两个测试框架.
是否有可能?我们如何在build.gradle
文件中指定它?我们如何配置我们的jenkins机器以针对不同的测试框架执行不同的任务?
Espresso uses the android.support.test.runner.AndroidJUnitRunner
while Robotium uses the aforementioned and first, we would like to be able to use both testing frameworks at the same time.
Is it possible? How can we specify that in the build.gradle
file? How can we configure our jenkins machine to have different jobs for the different testing frameworks?
我知道有可能让Espresso扩展ActivityInstrumentationTestCase2
,因为我们的Robotium测试类也使用了从ActivityInstrumentationTestCase2
扩展的测试运行器,但是我们仍然需要解决仪器测试运行器的问题.
I understand it is possible to have Espresso extend the ActivityInstrumentationTestCase2
, since our Robotium test classes also use a test runner which extends from ActivityInstrumentationTestCase2
, but we still need to tackle the problem of the instrumentation test runner.
推荐答案
从Android开发人员文档中,AndroidJUnitRunner
替换了较早的InstrumentationTestRunner
并启用了JUnit 4测试.
From the Android developer docs, AndroidJUnitRunner
replaces the older InstrumentationTestRunner
and enables JUnit 4 tests.
AndroidJUnitRunner
类是JUnit
测试运行程序,可让您在Android设备上运行JUnit 3
或JUnit 4
风格的测试类,包括使用Espresso
和UI Automator
测试框架的类.
The
AndroidJUnitRunner
class is aJUnit
test runner that lets you runJUnit 3
orJUnit 4
-style test classes on Android devices, including those using theEspresso
andUI Automator
testing frameworks.
测试运行程序负责将您的测试包和被测试的应用程序加载到设备上,运行测试并报告测试结果.该类代替了仅支持JUnit 3测试的InstrumentationTestRunner
类.
The test runner handles loading your test package and the app under test to a device, running your tests, and reporting test results. This class replaces the InstrumentationTestRunner
class, which only supports JUnit 3 tests.
https://developer.android.com/training/testing/junit -runner.html
我还没有发现许多能够运行仪器测试(例如,使用Robotium)的示例.我一直在寻找自己的目的.
I've not found many examples of being able to run Instrumentation Tests (e.g. using Robotium). I've been looking for my own purposes.
The doc explains how to replace the test runner in your build.gradle
file https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests
这篇关于同时使用InstrumentationTestRunner和AndroidJUnitRunner与Robotium和Espresso的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!