How do I get more details about failed test assertions on the shell?

Running tests by gradle at the shell tells me that an assertion has failed, in which class and which line, but none of e.g. the messages provided to the assertion itself. With only the class and line it’s pretty difficult to know what the cause might be, how important it is to look at etc. Especially because in my assertions I do provide some messages which would make it easier to decide that. If tests are run in e.g. Jenkins, the mails generated by that lack those details as well.

So is there some option or some way to configure test execution or whatever to provide a little bit more details about the actual problem? Or is the concept really that one has to look at the reports for that?

One example for what I get:

C:\[...]>gradlew integTest

> Task :integTest

de.am_soft.docbeam.raw.server.MainTest > procRun() FAILED
	org.opentest4j.AssertionFailedError at MainTest.java:114

4 tests completed, 1 failed

> Task :integTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':integTest'.
> There were failing tests. See the report at: file:///C:/[...]/build/reports/tests/integTest/index.html

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 4s
4 actionable tasks: 1 executed, 3 up-to-date

C:\[...]>

I would like to have some more details around the line org.opentest4j.AssertionFailedError at MainTest.java:114 and providing --stacktrace doesn’t help here.

Thanks!

1 Like

You can fine tune the test task output via the testLogging block.

I normally use:

test {
	testLogging {
		events "failed"
		exceptionFormat "full"
	}
}
  test {
    testLogging {
      events "passed", "skipped", "failed" //, "standardOut", "standardError"

      showExceptions true
      exceptionFormat "full"
      showCauses true
      showStackTraces true

      showStandardStreams = false
    }
  }
1 Like