Here we going to figure out few tips how to make your test failures more informative, clear and valuable with AssertJ custome messages.
AssertJ Maven dependency
Check the current available version - AssertJ
By default AssertJ assertion failures
give fail mesagges like this:
We can’t see what exactly the failure is about.
Let’s tune it a little with as(...)
method
or even
Better?
We also can completely replace the failure message with our custome message using withFailMessage(...)
:
And the last thing - don’t forget to give clear and informative names to test classes and test methods.
You may also find these posts interesting: