Gradle Display test results in Console

摘要: By default, the test result will not display in the console.

By default, the test result will not display in the console.

$ gradle test
Starting a new Gradle Daemon for this build (subsequent builds will be faster).
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
BUILD SUCCESSFUL
Total time: 7.78 secs

P.S The Gradle test report will be generated in $project/build/reports/index.html

1. Display test result

To diplay the test result in console, add the following test events :

build.gradle
test {
	//we want display the following test events
    testLogging {
        events "PASSED", "STARTED", "FAILED", "SKIPPED"

Run the test process again, the test classes, methods and status will be displayed.

$ gradle clean test
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
com.mkyong.helloworld.TestController > test_welcome2 STARTED
com.mkyong.helloworld.TestController > test_welcome2 PASSED
//...
BUILD SUCCESSFUL
Total time: 7.78 secs

2. Extra

Review a Gradle testLogging example from the official documentation

build.gradle
apply plugin: 'java'
test {
    testLogging {
        // set options for log level LIFECYCLE
        events "failed"
        exceptionFormat "short"
        // set options for log level DEBUG
        debug {
            events "started", "skipped", "failed"
            exceptionFormat "full"
        // remove standard output/error logging from --info builds
        // by assigning only 'failed' and 'skipped' events
        info.events = ["failed", "skipped"]

References

  1. Enum TestLogEvent
  2. TestLoggingContainer
  3. Gradle – How to exclude some tests

上一篇: Gradle How to continue build if test is failed
下一篇: Java How to print an Array
 评论 ( What Do You Think )
名称
邮箱
网址
评论
验证
   
 

 


  • 微信公众号

  • 我的微信

站点声明:

1、一号门博客CMS,由Python, MySQL, Nginx, Wsgi 强力驱动

2、部分文章或者资源来源于互联网, 有时候很难判断是否侵权, 若有侵权, 请联系邮箱:summer@yihaomen.com, 同时欢迎大家注册用户,主动发布无版权争议的 文章/资源.

3、鄂ICP备14001754号-3, 鄂公网安备 42280202422812号