同时使用InstrumentationTestRunner和AndroidJUnitRunner与Robotium和Espresso [英] Use both InstrumentationTestRunner and AndroidJUnitRunner with Robotium and Espresso

查看:279
本文介绍了同时使用InstrumentationTestRunner和AndroidJUnitRunner与Robotium和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 3JUnit 4风格的测试类,包括使用EspressoUI Automator测试框架的类.

The AndroidJUnitRunner class is a JUnit test runner that lets you run JUnit 3 or JUnit 4-style test classes on Android devices, including those using the Espresso and UI 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.

该文档说明了如何替换build.gradle文件

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆