assertk icon indicating copy to clipboard operation
assertk copied to clipboard

Missing representation

Open SerVB opened this issue 2 years ago • 3 comments

Hi! I'm comparing assertk to assertj and bumped into innability to find a way to change representations in the assertions message (Assertions.useRepresentation).

Does it exist or is it not yet implemented?

IMO that is quite useful, and should be provided ootb.

SerVB avatar Dec 02 '22 16:12 SerVB

You can pass a custom display function when calling assertThat ex:

assertThat(foo, displayActual = { myCustomRepresentation(it) })

this could probably be better documented.

Does this cover the use-cases you are envisioning?

evant avatar Nov 30 '23 20:11 evant

Thanks for the answer. This looks not so convenient, though, to always pass the display function. It's better to just somehow specify globally.

SerVB avatar Dec 01 '23 09:12 SerVB

Oh you mean specifically a global setting then? Extending how show() works is something I've considered, but doing that in a way that's ergonomic and easy to understand is tricky.

evant avatar Dec 01 '23 19:12 evant