I have the following code which should test my RESTful API:
given().baseUri("http://...").get("/categories/all")
.then()
.body(
"results", not(empty())
);
The API returns the following response:
{
"error": {
"type": "NotFoundException"
}
}
And I want the test to fail for such response. But the test passes.
How can I modify the test to make it fail? It should only pass if the API returns an object which contains a not-empty array in the "results" key. It should fail when the "results" key does not exists, contains empty array or when it contains something that is not an array.