Skip to content

assertEquals fails #10

Closed
Closed

Description

@Neurone

At line 172 of Test.java file there's an "assertEquals" failing.

This is the expected:

{"cook_time":"3 hours","name":"bread","tagName":"recipe","childNodes":[{"tagName":"title","childNodes":["Basic bread"]},{"amount":8,"unit":"dL","tagName":"ingredient","childNodes":["Flour"]},{"amount":10,"unit":"grams","tagName":"ingredient","childNodes":["Yeast"]},{"amount":4,"unit":"dL","tagName":"ingredient","state":"warm","childNodes":["Water"]},{"amount":1,"unit":"teaspoon","tagName":"ingredient","childNodes":["Salt"]},{"tagName":"instructions","childNodes":[{"tagName":"step","childNodes":["Mix all ingredients together."]},{"tagName":"step","childNodes":["Knead thoroughly."]},{"tagName":"step","childNodes":["Cover with a cloth, and leave for one hour in warm room."]},{"tagName":"step","childNodes":["Knead again."]},{"tagName":"step","childNodes":["Place in a bread baking tin."]},{"tagName":"step","childNodes":["Cover with a cloth, and leave for one hour in warm room."]},{"tagName":"step","childNodes":["Bake in the oven at 180(degrees)C for 30 minutes."]}]}],"prep_time":"5 mins"}

and this is the actual one:

{"cook_time":"3 hours","childNodes":[{"childNodes":["Basic bread"],"tagName":"title"},{"unit":"dL","childNodes":["Flour"],"tagName":"ingredient","amount":8},{"unit":"grams","childNodes":["Yeast"],"tagName":"ingredient","amount":10},{"state":"warm","unit":"dL","childNodes":["Water"],"tagName":"ingredient","amount":4},{"unit":"teaspoon","childNodes":["Salt"],"tagName":"ingredient","amount":1},{"childNodes":[{"childNodes":["Mix all ingredients together."],"tagName":"step"},{"childNodes":["Knead thoroughly."],"tagName":"step"},{"childNodes":["Cover with a cloth, and leave for one hour in warm room."],"tagName":"step"},{"childNodes":["Knead again."],"tagName":"step"},{"childNodes":["Place in a bread baking tin."],"tagName":"step"},{"childNodes":["Cover with a cloth, and leave for one hour in warm room."],"tagName":"step"},{"childNodes":["Bake in the oven at 180(degrees)C for 30 minutes."],"tagName":"step"}],"tagName":"instructions"}],"tagName":"recipe","name":"bread","prep_time":"5 mins"}

Activity

  1. douglascrockford commented on Jan 13, 2011

    @douglascrockford
    Contributor

    You might have noticed this statement at the top of Test.java:

    • Issue: JSONObject does not specify the ordering of keys, so simple-minded
    • comparisons of .toString to a string literal are likely to fail.

    So the basic junit stuff is simply inadequate. But it is very popular, so it must be a good thing.

  2. Neurone commented on Jan 13, 2011

    @Neurone
    Author

    Oh, I suspected it was a keys ordering related issue but I didn't noticed your comments at the top of the file. Anyway, if a case can't be tested, I think removing it at all will be a better solution. Or at least it could be isolated just to show a possible toString() method misunderstanding, because that single fault currently prevents following tests inside testJSON() method to be executed.

    I noticed sarcasm in your words about JUnit also ^^ Why do you think it's not a good choice? You don't like TDD or JUnit in particular?

  3. douglascrockford commented on Jan 13, 2011

    @douglascrockford
    Contributor

    If it were any good, you would not have filed the original report.
    Simplistic solutions are great when they work.

  4. added a commit that references this issue on Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions