Clues
note
Clues only work if you are using the Kotest test framework in conjuction with the assertions library
Sometimes a failed assertion contains enough information in the error message to know what went wrong.
For example:
Might give an error like:
And you would be able to see that you were populating the username field with an email address.
But let's say you had a test like this:
If this failed, you would simply get:
Which isn't particularly helpful. This is where withClue
comes into play.
The withClue
and asClue
helpers can add extra context to assertions so failures are self explanatory:
For example, we can use withClue
with a string message
Would give an error like this:
We can also use the asClue
extension function to turn any object into the clue message.
For example:
Would output: