I am using JUnit 4 to write Android test cases (these tests are not using the Emulator and are running as native tests). Within my code I use SL4J for logging, however when I run the unit tests, I am not able to see any of the logging output. For example statements such as the following:
private static final Logger logger = LoggerFactory.getLogger(AClass.class);
logger.warn("log output not visible in unit test");
Any ideas on if it is possible to get access to the logger output in unit tests?
Regards,
I have answered this before but I cannot find the link to the answer right now.
Here is the Android gradle plugin solution:
android {
// ...
testOptions.unitTests.all {
testLogging {
events 'passed', 'skipped', 'failed', 'standardOut', 'standardError'
}
}
}
Here is the solution I use for any Gradle test:
tasks.withType(Test) {
testLogging {
exceptionFormat 'full'
showCauses true
showExceptions true
showStackTraces true
showStandardStreams true
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With