包含和排除特定测试
test类有一个include和一个exclude方法。这些方法可用于指定应实际运行哪些测试。
仅运行包含的测试-
test {
include '**my.package.name/*'
}
跳过排除的测试-
test {
exclude '**my.package.name/*'
}
如下所示的示例build.gradle文件显示了不同的配置选项。
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 )
}
}
您可以使用以下命令语法来执行一些测试任务。
gradle <someTestTask> --debug-jvm