Removing flakiness using .json() to check JSON string responses#96
Open
akshathphillips wants to merge 1 commit intodyc87112:masterfrom
Open
Conversation
…rt the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking
|
您好!我已收到的您的来信,并会尽早查收。———————————————————— 葛晓飞
|
|
这是一封自动回复邮件。已经收到您的来信,我会尽快回复。
|
|
这是来自QQ邮箱的假期自动回复邮件。
您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Author
|
Hello. Any updates on this? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this PR
com.didispace.chapter21.Chapter21ApplicationTestsWhy the tests fail
String.class, the order of the fields inside the object may change to be in random positions. For example,{"id":1, "age":20}, or {"age":20, "id":1}Reproduce the test failure
mvn -pl 2.x/chapter2-1 test edu.illinois:nondex-maven-plugin:2.1.1:nondex -Dtest=com.didispace.chapter21.Chapter21ApplicationTests#testUserController -DnondexRuns=10Expected results
Actual Result
We get the following failure for test
com.didispace.chapter21.Chapter21ApplicationTestsFix
For test
com.didispace.chapter21.Chapter21ApplicationTests- Parse the expected and actual strings as JSON and assert the two are "similar" - i.e. they contain the same attribute-value pairs regardless of formatting with a lenient checking. The .json(), does a lenient checking on the fields, which solves this issue.