如何提取一些单元测试以分离Gradle测试任务? [英] How to extract some unit tests to separate gradle test task?
本文介绍了如何提取一些单元测试以分离Gradle测试任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比方说,我想将Robolectric测试与普通单元测试分开,并将它们作为单独的gradle任务运行.是否有可能?
Let's say I want to separate Robolectric tests from normal unit tests and run them as separate gradle task. Is it possible?
我设法从单元测试中排除了不需要的测试:
I've managed to exclude unwanted tests from unit tests:
android {
...
testOptions {
unitTests.all {
exclude 'package/with/robolectric/tests/**'
}
}
}
但是现在我不确定如何配置单独的测试任务,该任务仅包括来自package/with/robolectric/tests/
程序包的测试.
but now I'm unsure how to configure separate test task which will include only tests from package/with/robolectric/tests/
package.
我发现了类似的问题,但答案不起作用: 使用gradle与android进行单独的集成测试任务
I found similar problem but the answer is not working: Separate integration test task on gradle with android
推荐答案
更改为
testOptions {
if (!project.hasProperty("INTEGRATIONTESTS")) {
unitTests.all {
exclude 'package/with/robolectric/tests/**'
}
}
}
并使用-PINTEGRATIONTESTS=true
这篇关于如何提取一些单元测试以分离Gradle测试任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文