Gradle Android:如何在不使用--info的情况下显示测试结果 [英] Gradle Android: How to Display test results without using --info
问题描述
我正在使用Gradle Android插件运行android测试,并希望看到单个测试结果。 Garddle:如何在控制台中实时显示测试结果?看起来我可以使用 - info
(它可以打印很多我不关心的其他详细垃圾)或者使用这个仅适用于Java插件的闭包(不是Android插件)
测试{
afterTest {desc,result - >
println结果执行测试$ {desc.name} [$ {desc.className}]:$ {result.resultType}
}
}
当我运行 connectedCheck
任务时,是否有其他选项/闭包可用于打印单个测试结果没有所有其他的冗长。 使用结果
Gradle info
这将打印来自 Gradle
的所有信息:
gradle --info
< h2>或使用Android Gradle
插件:
android.testOptions.unitTests .all {
//配置失败的测试是否应该失败构建
ignoreFailures false
testLogging {
eventspassed,skipped,failed, standardOut,standardError
}
}
或使用<$直接使用c $ c> Gradle :
allprojects {
tasks.withType(Test) {
testLogging {
exceptionFormatfull
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
events = [passed, 跳过,失败,standardOut,standardError]
}
}
}
allprojects {
tasks.withType(Test) {
testLogging {
exceptionFormatfull
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
events = [passed, 跳过,失败,standardOut,standardError]
}
}
}
输出:
io。 github.hidroh.materialistic.data.SessionManagerTest> testView PASSED
io.github.hidroh.materialistic.data.SessionManagerTest> testIsViewFalse PASSED
io.github.hidroh.materialistic.data.SessionManagerTest> testIsViewNull PASSED
io.github.hidroh.materialistic.data.SessionManagerTest> testIsViewTrue PASSED
io.github.hidroh.materialistic.data.SessionManagerTest> testViewNoId PASSED
来源: https://github.com/hidroh/materialistic/blob/master/robolectric.gradle
Gradle文档: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/logging/TestLogEvent.html
I am running android tests using the Gradle Android plugin and want to see individual test results.
From answers to this Question Gradle: How to Display Test Results in the Console in Real Time? it seems I can either use --info
(which prints a LOT of other verbose junk I don't care about) or use this closure which only works for the Java plugin (not the Android plugin)
test {
afterTest { desc, result ->
println "Executing test ${desc.name} [${desc.className}] with result: ${result.resultType}"
}
}
Is there some other option / closure I can use when I am running the connectedCheck
task just to print the individual test results without all the other "verbosity".
Use Gradle
info
This will print all information from Gradle
:
gradle --info
or Use Android Gradle
plugin:
android.testOptions.unitTests.all {
// Configure whether failing tests should fail the build
ignoreFailures false
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
}
}
or Use Gradle
directly:
allprojects {
tasks.withType(Test) {
testLogging {
exceptionFormat "full"
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
events = ["passed", "skipped", "failed", "standardOut", "standardError"]
}
}
}
Output:
io.github.hidroh.materialistic.data.SessionManagerTest > testView PASSED
io.github.hidroh.materialistic.data.SessionManagerTest > testIsViewFalse PASSED
io.github.hidroh.materialistic.data.SessionManagerTest > testIsViewNull PASSED
io.github.hidroh.materialistic.data.SessionManagerTest > testIsViewTrue PASSED
io.github.hidroh.materialistic.data.SessionManagerTest > testViewNoId PASSED
Source: https://github.com/hidroh/materialistic/blob/master/robolectric.gradle
Gradle Docs: https://docs.gradle.org/current/javadoc/org/gradle/api/tasks/testing/logging/TestLogEvent.html
这篇关于Gradle Android:如何在不使用--info的情况下显示测试结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!