Issue
I'm currently using rest assured and Json-unit to assert a local json file against the requested rest assured response.
I currently have a before class method with my base uri.
I don't know how to make this assertion. I'm struggling with the json-unit documentation. Do I need to input a file first?
@Test
public void ApiaryTest1() throws Exception {
when()
.get("/test")
.then()
.statusCode(200);
// compares two JSON documents
assertJsonEquals("expected/test.json", "http://apiary/test");
}
Solution
You need to:
- Read in the resource with the JsonUnit API
- Extract the response from rest assured to a variable
- Assert you are already doing
Example:
Response response = when().get("<url>");
response
.then()
.statusCode(200);
// compares two JSON documents
assertJsonEquals(resource("resource-inside-resources-folder.json"), response.asString());
Answered By - pedromss
Answer Checked By - Senaida (JavaFixing Volunteer)