Gradle Android:如何在不使用--info的情况下显示测试结果 [英] Gradle Android: How to Display test results without using --info

查看:180
本文介绍了Gradle Android:如何在不使用--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]
}
}
}

请参阅: https://github.com/jaredsburrows/android-gradle-java-app-template/blob/master/gradle/compile.gradle#L20



输出:

  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"]
        }
    }
}

See: https://github.com/jaredsburrows/android-gradle-java-app-template/blob/master/gradle/compile.gradle#L20

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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆