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

Misleading assertion output #101

Open
eximius313 opened this issue Feb 12, 2018 · 2 comments
Open

Misleading assertion output #101

eximius313 opened this issue Feb 12, 2018 · 2 comments

Comments

@eximius313
Copy link

when running following assertion:

    assertThatJson("[\"foo\", \"bar\"]")
    .isArray()
    .ofLength(2)
    .thatContains("foo")
    .thatContains("bar");

I get this output:

net.javacrumbs.jsonunit.difference.diff - JSON documents are different:
Different value found in node "", expected: <"bar"> but was: <"foo">.
net.javacrumbs.jsonunit.difference.values - Comparing expected:
"bar"
------------
with actual:
"foo"

There are two problems with this.

  1. As element is found on the list, it shouldn't matter if it's on first or second position, because assertions is contains not containsInExactOrder, thus the message shouldn't be displayed at all.
  2. Different value found in node "" - what this empty string means anyway?
lukas-krecan added a commit that referenced this issue Feb 14, 2018
@lukas-krecan
Copy link
Owner

Hi, thanks for feedback. The exact same test passes in my builds (https://travis-ci.org/lukas-krecan/JsonUnit) https://travis-ci.org/lukas-krecan/JsonUnit/builds/341573416 so I guess that something else is wrong. As for the empty string, it's path to the element. In this case it's root so it's empty. I admit that json-path "$" would have been more understandable.

@eximius313
Copy link
Author

Well, the test passes for me as well - the debug message is misleading. It seems that you were also tricked by it ;)

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