assertj / assertj-vavr

Assertions for Vavr - http://www.vavr.io/
Apache License 2.0
52 stars 16 forks source link

Assertion error message for containsOnLeft doesn't contain actual left value #122

Closed sesamzoo closed 4 years ago

sesamzoo commented 4 years ago

Description

50 hasn't completely fixed assertion error messages on Either, because of this line in assertj-core's StandardRepresentation:

    if (object instanceof Iterable<?>) return smartFormat((Iterable<?>) object);

This might affect other assertion error messages, too.

Example

assertThat(Either.left("hello")).containsOnLeft("hello world");

Expected Behavior

leads to an assertion error message containing the actual value, f.i. like

Expecting: <"Left(hello)"> to contain: <"hello world"> on the [LEFT] but did not.

Actual Behavior

leads to assertion error message

Expecting: <[]> to contain: <"hello world"> but did not.

Tested with

mchmielarz commented 4 years ago

Good catch. I'll fix it

sesamzoo commented 4 years ago

With upgrading to latest assertj-core release 3.18.0 this issue will be gone, because its StandardRepresentation does

Honor toString if overridden in Iterable that are not collections.

Update: So, I guess #125 also fixed this issue.

mchmielarz commented 4 years ago

That's true. It wasn't fixed in the project because of custom error message factories. I'll update them and will be fine