willowtreeapps / assertk

assertions for kotlin inspired by assertj
MIT License
774 stars 87 forks source link

Missing representation #433

Open SerVB opened 1 year ago

SerVB commented 1 year ago

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.

evant commented 11 months ago

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?

SerVB commented 11 months ago

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

evant commented 11 months ago

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.