SpringBoot-Learning
SpringBoot-Learning copied to clipboard
Fix a flaky test testUserController
This PR is to fix a flaky test com.didispace.chapter21.Chapter21ApplicationTests#testUserController
in module 2.x/chapter2-1
, we found it when using the latest version of SpringBoot-Learning:
- To reproduce test failures:
- Run the following cmds:
mvn edu.illinois:nondex-maven-plugin:2.1.1:nondex -pl 2.x/chapter2-1 -Dtest=com.didispace.chapter21.Chapter21ApplicationTests#testUserController -DnondexRuns=10
- Then we'll get failures:
Chapter21ApplicationTests.testUserController:52 Response content
Expected: "[{\"id\":1,\"name\":\"测试大师\",\"age\":20}]" but: was "[{\"age\":20,\"name\":\"测试大师\",\"id\":1}]"
-
Why it fails: Line 52 of
2.x/chapter2-1/src/test/java/com/didispace/chapter21/Chapter21ApplicationTests.java
converts a JSON object to a string. Note that this conversion does not guarantee the order of the elements. -
Fix: Use
json()
to compare Json objects instead of converting them to string.
您好!我已收到的您的来信,并会尽早查收。———————————————————— 葛晓飞
这是一封自动回复邮件。已经收到您的来信,我会尽快回复。
这是来自QQ邮箱的假期自动回复邮件。您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。