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

testXML fails #28

Closed
yincrash opened this issue Oct 24, 2011 · 6 comments
Closed

testXML fails #28

yincrash opened this issue Oct 24, 2011 · 6 comments

Comments

@yincrash
Copy link

I just downloaded the source and ran the Test JUnit tests. I'm not sure the expected text is correct.

@douglascrockford
Copy link
Contributor

So?

@yincrash
Copy link
Author

It's not a bug to have a failing test?

@douglascrockford
Copy link
Contributor

The test framework is crap because it depends on the ordering of Objects, ignoring the fact that objects are not ordered. So because of that, the tests are not portable. Is that why the tests are failing for you? There is no way I can answer that given the information you chose to share.

@yincrash
Copy link
Author

This is the failure trace:

junit.framework.ComparisonFailure: expected:<..."subsonic-response":["playlists":{"playlist":[{"id":"476c65652e6d337"},]"id":"50617274792e78...> but was:<..."subsonic-response":[{"playlists":{"playlist":[{"id":"476c65652e6d3375"},{]"id":"50617274792e78...>
    at junit.framework.Assert.assertEquals(Assert.java:81)
    at junit.framework.Assert.assertEquals(Assert.java:87)
    at org.json.Test.testXML(Test.java:73)

The failure doesn't have to do with order. The syntax of the expected text is incorrect in that there appear to be a couple of characters missing. The opening '{' for the right hand side of the "subsonic-response" property. The '{' of the second object in the 'playlist' array, and the last '5' in the first id.

@yincrash
Copy link
Author

If toString comparisons are not a reasonable test because of order, but there is a test verifying string to JSONObject, couldn't you make a valid test case by converting the string to a JSONObject and comparing JSONObjects? Assuming there is a JSONObject equals() implementation.

I wouldn't mind submitting a patch for it. Better to have test cases that are useful than ones that are inherently not trustworthy.

@douglascrockford
Copy link
Contributor

Go for it. The current test framework was donated. I am sorry now that I accepted it.

BGehrels pushed a commit to BGehrels/JSON-java that referenced this issue Apr 29, 2020
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