Hamcrest assertThat() error - objects are not the same

299 Views Asked by At

I have trouble with comparing two object.

var response = api.getRequest();
response.statusCode(200);

response.body(JsonSchemaValidator.matchesJsonSchema....);

var bodyResponse = response.extract().as(ExampleResponse.class);
var bodyExpected = ExampleResponse.builder()...build().

assertThat("Response body is not the same with expected body",bodyResponse, equalTo(bodyExpected));

In test I'm getting error that response body and expected are not the same :/

I couldn't upload image with compared object but belive me, they are the same (I checked in debugger) :)

Thanks for any tips :)

1

There are 1 best solutions below

0
On

Java uses the equals Method to check for equality. You need to implement this!

See here