我做了很多搜索,但遗憾的是无法让它发挥作用。
根据我的搜索,我发现需要在build.gradle文件中添加以下代码。但是,Gradle似乎无法识别它并总是说Geadle DSL method not found: test()
test {
testLogging.showStandardStreams = true
testLogging.events("passed", "skipped", "failed", "standardOut", "standardError")
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
我可以确认上面的代码或者比以下代码更好,如果您创建一个测试项目并将所有测试用例移到主项目中而不是src/test/java
和src/androidTest/java
中。这是因为您可以在build.gradle文件中应用java
插件。但是,在com.android.*
已定义的任何build.gradle文件中无法使用以下代码。由于这两个库不兼容:(
apply plugin: 'java'
evaluationDependsOn(':YOUR-LIB')
test {
testLogging.showStandardStreams = true
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
exceptionFormat = 'full'
}
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
forkEvery = 5
maxParallelForks = java.lang.Runtime.runtime.availableProcessors() / 2
}
tasks.withType(Test) {
// Need Gradle to ignore classes that are inner class of Test classes but not actually Tests
scanForTestClasses = false
include "**/*Test.class"
}
所以,我的问题是,是否有人以任何方式在android
插件下打印日志?