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
Copy
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"
}
}
Copy
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
Copy
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"]
}
}
No comments:
Post a Comment