lilinkevin / rest-assured

Automatically exported from code.google.com/p/rest-assured
0 stars 0 forks source link

Output format when comparing entire JSON bodies is hard to read #357

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a test where you compare the entire body of a response that is JSON
2. Look at the output in IntelliJ
3. Try to determine which field is wrong when there is a big payload

What is the expected output? What do you see instead?
We would expect it to be easy to see the exact part of the payload that 
differs. When debugging, the specific error seems to be part of the Hamcrest 
mismatch description, but it gets discarded/is ignored by RESTAssured, meaning 
we see something like this:

Expected: "{\"errors\":[{\"code\":503,\"message\":\"Internal database 
errors\"}]}"
  Actual: {"errors":[{"code":503,"message":"Internal database error"}]}

This isn't too bad for a small payload, but when you have bigger response 
bodies with HAL etc, you end up needing to paste into an editor, remove the 
backspaces etc just to try to determine what is up. 

What version of the product are you using? On what operating system?
2.3.3 - OSX 10.9.4

Please provide any additional information below.

We are comparing the body by providing a fixture, such as

                body(matchesJsonFixture("fixtures/database_exception_error_response.json")).

matchesJsonFixture looks like this:
    public static SameJSONAs<? super String> matchesJsonFixture(String fixtureLocation) {
        String fixtureContent = fixture(fixtureLocation);
        String normalisedJson = new JsonParser().parse(fixtureContent).toString();
        return sameJSONAs(normalisedJson);
    }

But I don't think this is the problem. Thanks

Original issue reported on code.google.com by mikeycmc...@gmail.com on 29 Sep 2014 at 1:07

GoogleCodeExporter commented 9 years ago
Do you have any suggestions for how to solve this in a generic way?  I cannot 
think of a generic solution for this on top of my head.

Original comment by johan.ha...@gmail.com on 1 Oct 2014 at 6:43

GoogleCodeExporter commented 9 years ago
I'll try to knock up a small example and have a think. Are you able to see
the issue? When I debut through it seems that the hamcrest object has the
necessary details but it seems to get swallowed. The only thing I can think
to do is extract the body and doing a separate assertion afterwards, which
isn't as nice as the fluent restassured style we are bug fans of.

Thanks!

Original comment by mikeycmc...@gmail.com on 1 Oct 2014 at 6:48