3

Is there a way to log all assertions, not just failing ones?

I wonder whether AssertJ provides an interface to access the details of the assertion (WritableAssertionInfo) and the result of the assertion? Is there any way to hook into the assertion process and add a simple log output?

I checked the documentation, the Java API and some related questions (like this one) but couldn't find a solution to my use-case.

martin
  • 2,150
  • 1
  • 34
  • 48
  • Wondering if you have solved this issue somehow? – Neruul Jul 16 '20 at 10:50
  • Unfortunately, not yet. I still believe this should be supported on the framework level but it's not trivial to add this functionality to an existing framework which wasn't designed with that use-case in mind. There is a conversation on the AssertJ Github issue: https://github.com/joel-costigliola/assertj-core/issues/1518. When I have more time I will look into it again and see if I can help to build it or whether my use-case could be more easily achieved with another assertion library. – martin Jul 17 '20 at 11:17

1 Answers1

1

Nope, only failed assertions lead to (error) messages, there is recording of what is being asked.

I'm curious to know what problem you are trying to solve if you can share it.

Joel Costigliola
  • 6,308
  • 27
  • 35
  • 1
    I want to add a "test protocol" to the log file and list all checks that have been performed, not just the failed ones. AssertJ allows us to write very descriptive tests (by adding descriptions to each check), it would be useful if we could utilise this information not just when things go wrong. – martin Jun 05 '19 at 02:40
  • 1
    Could you create an issue in github for that, I can't promise it is going to be tackled quickly but at least it would be recorded as a wished feature. – Joel Costigliola Jun 05 '19 at 02:54