【问题标题】:How to extract some unit tests to separate gradle test task?如何提取一些单元测试来分离 gradle 测试任务?
【发布时间】:2017-05-04 09:56:09
【问题描述】:

假设我想将 Robolectric 测试与普通单元测试分开,并将它们作为单独的 gradle 任务运行。可能吗?

我已经设法从单元测试中排除不需要的测试:

android {
    ...

    testOptions {
        unitTests.all {
            exclude 'package/with/robolectric/tests/**'
        }
    }
}

但现在我不确定如何配置单独的测试任务,该任务将仅包含来自 package/with/robolectric/tests/ 包的测试。

我发现了类似的问题,但答案不起作用: Separate integration test task on gradle with android

【问题讨论】:

    标签: android unit-testing android-studio gradle


    【解决方案1】:

    改成

    testOptions {
        if (!project.hasProperty("INTEGRATIONTESTS")) {
            unitTests.all {
                exclude 'package/with/robolectric/tests/**'
            }
        }
    }
    

    并使用 -PINTEGRATIONTESTS=true 运行 Gradle

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-23
      • 2016-10-03
      • 1970-01-01
      • 1970-01-01
      • 2014-04-08
      • 2018-12-20
      相关资源
      最近更新 更多