I'm trying to print more logs to my console by following this post: https://stackoverflow.com/a/36130467, but I keep getting these errors:
- Cannot resolve symbol testLogging
- Cannot resolve symbol events
- Cannot resolve symbol exceptionFormat
- Cannot resolve symbol debug etc.
Here's my code
build.gradle file:
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
apply plugin: 'groovy'
apply plugin: 'idea'
apply plugin: 'java'
repositories {
jcenter()
mavenCentral()
}
tasks.withType(Test) {
testLogging {
// set options for log level LIFECYCLE
events TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
showExceptions true
showCauses true
showStackTraces true
// set options for log level DEBUG and INFO
debug {
events TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
exceptionFormat TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
def output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
def startItem = '| ', endItem = ' |'
def repeatLength = startItem.length() + output.length() + endItem.length()
println('\n' + ('-' * repeatLength) + '\n' + startItem + output + endItem + '\n' + ('-' * repeatLength))
}
}
}
}
dependencies {
testImplementation group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.4.10'
testImplementation group: 'org.spockframework', name: 'spock-unitils', version:'1.1-groovy-2.4-rc-4'
}