我确实搜索了很多,但不幸的是无法让它工作。
根据我的搜索,我发现我需要将以下代码添加到 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
。这是因为您可以java
在 build.gradle 文件中应用插件。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
插件下的日志?