Assertion error details lost in rethrow in assertWithDiagnostics #26303
Labels
in: test
Issues in the test module
in: web
Issues in web modules (web, webmvc, webflux, websocket)
type: enhancement
A general enhancement
Milestone
The issue is caused by
org.springframework.test.web.reactive.server.ExchangeResult.assertWithDiagnostics
which catches AssertionError, adds diagnostic information and throws a new AssertionError.The trouble is, that if you use an assertion library in
WebTestClient.consumeWith
the assertion library throws an exception with details likeorg.opentest4j.AssertionFailedError
. The details are used by IDEs when displaying difference between expected and actual value. By rethrowing generic AssertionError, the extra details are lost and the IDE has to use heuristics to guess the difference (for example like this this).To make it worse, if the IDE guesses wrong, it adds the debugging information from
assertWithDiagnostics
to the expected value in the difference view which is really confusing.The best way would be to rethrow the AssertionFailedError with related detail but I understand that it would add complexity and may require reflection to not break the method when opentest4j is not on the classpath
The text was updated successfully, but these errors were encountered: