Reputation: 43
I am using assertj's tuple to combine two or three property together and check the combination. Now I am having the issue of identifying out of which property it is failing.
Currently am using the as below:
softAssertions.assertThat(resultArrayList)
.extracting("title", "address.countryName", "address.state", "address.city")
.as("Title, CountryName, State, City at position %s", i)
.containsAnyOf(
new Tuple(placeToSearch, expectedCountry, expectedState, expectedCity));
and I get a failure message as
[Title, CountryName, State, City at position 0]
Expecting
<[("DOT Baires Shopping", "Argentina", "Ciudad Autónoma de Buenos Aires", "Ciudad de Buenos Aires")]>
to contain at least one of the following elements:
<[("Dot", "Argentina", "Ciudad Autónoma de Buenos Aires", "Ciudad de Buenos Aires")]>
1) Some suggestion to identify/mark the failed data. 2) Any way to colour the failed ones
Upvotes: 0
Views: 400
Reputation: 7116
In your case you have a list of one tuple, this tuple does not match the expected tuple as their first value differ ("Dot"
vs "DOT Baires Shopping"
). Tuple equals
method compares all tuple values.
It should be possible to color the actual and expected list but not specific elements (it's an IDE thing, not really an AssertJ thing).
A few remarks:
containsAnyOf(expected)
with one element is the same as using contains(expected)
Assertions
expose a tuple(...)
factory method to avoid calling new Tuple(...)
Hope it helps
Upvotes: 0