Search code examples
assertj

Assertj extract and contains doesn't match


I made a simple test :

Person p = new Person();
p.setFirstName("Stéphane");
p.setLastName("Traumat");

assertThat(p)
.extracting("firstName", "lastName")
.contains(tuple("Stéphane", "Traumat"));

And I get a strange result :

java.lang.AssertionError: 
Expecting:
<["Stéphane", "Traumat"]>
to contain:
<[("Stéphane", "Traumat")]>
but could not find:
<[("Stéphane", "Traumat")]>

Anyone can help me ?


Solution

  • Don't use a tuple, the result of extracting in your case is a simple array, please also have a look at the javadoc for extracting, it contains an example showing how to use it.