Gradle具有测试配置块
https://docs.gradle.org/current/dsl/org.gradle.api.tasks.testing.Test.html
```
apply plugin: 'java' // adds 'test' task
test {
// enable TestNG support (default is JUnit)
useTestNG()
// set a system property for the test JVM(s)
systemProperty 'some.prop', 'value'
// explicitly include or exclude tests
include 'org/foo/**'
exclude 'org/boo/**'
// show standard out and standard error of the test JVM(s) on the console
testLogging.showStandardStreams = true
// set heap size for the test JVM(s)
minHeapSize = "128m"
maxHeapSize = "512m"
// set JVM arguments for the test JVM(s)
jvmArgs '-XX:MaxPermSize=256m'
// listen to events in the test execution lifecycle
beforeTest { descriptor ->
logger.lifecycle("Running test: " + descriptor)
}
// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
}
}
其中一个可以设置各种测试配置(我最感兴趣的是堆大小)。 Android项目有类似的东西吗?
答案 0 :(得分:14)
有可能添加它们。 Android Gradle插件的参数为testOptions
,其参数为unitTests
,其中包含选项all
。
所以如果你写:
android {
testOptions {
unitTests.all {
///apply test parameters
}
}
}
将使用指定的参数执行测试。