gpt4 book ai didi

android - 将 InstrumentationTestRunner 和 AndroidJUnitRunner 与 Robotium 和 Espresso 一起使用

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:36:05 25 4
gpt4 key购买 nike

我们将 Robotium 与 android.test.InstrumentationTestRunner 一起用于我们的测试。尽管如此,我们还是想用 Espresso 替换 Robotium,但我们仍然对此有一些疑问,因为我们有一台带有 Jenkins 的机器用于 CI。

Espresso 使用 android.support.test.runner.AndroidJUnitRunner 而 Robotium 使用前面提到的,首先,我们希望能够同时使用这两个测试框架。可能吗?我们如何在 build.gradle 文件中指定它?我们如何配置我们的 jenkins 机器以针对不同的测试框架执行不同的作业?

我知道 Espresso 可以扩展 ActivityInstrumentationTestCase2,因为我们的 Robotium 测试类也使用从 ActivityInstrumentationTestCase2 扩展的测试运行器,但我们仍然需要解决插桩测试运行器的问题。

最佳答案

在 Android 开发者文档中,AndroidJUnitRunner 取代了旧的 InstrumentationTestRunner 并启用了 JUnit 4 测试。

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.

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

我没有找到很多能够运行 Instrumentation Tests 的例子(例如使用 Robotium)。我一直在寻找自己的目的。

文档解释了如何替换 build.gradle 文件中的测试运行器 https://developer.android.com/training/testing/unit-testing/instrumented-unit-tests

关于android - 将 InstrumentationTestRunner 和 AndroidJUnitRunner 与 Robotium 和 Espresso 一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36420344/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com