Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

proposal: more readable stack trace for big JSON payload with restito integration testing #70

Open
bieli opened this issue Sep 27, 2018 · 1 comment

Comments

@bieli
Copy link

bieli commented Sep 27, 2018

When I try to find bug in my JSON payload in integration tests using restito it doesn't support me with clear debug process.

For example output for failed test:

    Condition failed with Exception:

    verifyHttp(restitoServer) .once(post("/endpoint"), withPostBodyContainingJson(asString(mySpecialBigPayload)))
    |          |               |    |                     |                          |        |
    |          |               |    |                     |                          |        class path resource [payload_big.json]
    |          |               |    |                     |                          {
    |          |               |    |                     |                            "id": "51abb572-c22b-11e8-b3f9-699386e0b5fe-54091516",
    |          |               |    |                     |                            "prop": "value",
    |          |               |    |                     |                            "id": [
    |          |               |    |                     |                              "54091516"
    |          |               |    |                     |                            ],

... ~500 lines of big JSON

    |          |               |    |                     com.xebialabs.restito.semantics.Condition@6d442a82
    |          |               |    com.xebialabs.restito.semantics.ConditionWithApplicables@70b57756
    |          |               java.lang.AssertionError: Expected to happen 1 time(s), but happened 0 times instead
    |          com.xebialabs.restito.server.StubServer@73101e8b
    com.xebialabs.restito.builder.verify.VerifyHttp@7361820a
        at
 ...
        Caused by:
        java.lang.AssertionError: Expected to happen 1 time(s), but happened 0 times instead
            at com.xebialabs.restito.builder.verify.VerifyHttp.times(VerifyHttp.java:58)
            at com.xebialabs.restito.builder.verify.VerifyHttp.once(VerifyHttp.java:42)

I had wrong values in two JSON properties/fields and I think searching/debugging phase problems too longer than I expected.

Ideal solution it will be suggest what is different or probably wrong.

It will be possible to add more clear output when test failed ?

@mkotsur
Copy link
Owner

mkotsur commented Sep 27, 2018

Hi @bieli . Yes, that would be nice to have better error reporting in such cases. It's not very easy, though: conditions just return true/false without providing information about the difference. It could be possible, though, for some conditions (e.g. ones that check for equality). But then again, I'm not sure if it is useful to see the log of all not satisfied conditions. There can be too many...

But let me ask you, what do withPostBodyContainingJson and asString do? They are not part of restito afaik. Is it your custom condition?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants