Open DevDengChao opened 1 year ago
I think there could be a net.minidev:json-smart-matchers:<version>
package, and encourage downstream testing packages to include it by default.
Hello, @DevDengChao According to the context, I think methods and ability should be add in the JsonProvider interface If SpringMvc still uses JsonPath?
Or say you want SringMvc directly uses JsonSmart, and we add these abilities to JsonSmart?
I think methods and ability should be add in the JsonProvider interface If SpringMvc still uses JsonPath
:+1:
Then here comes a question, should JsonPath be responsible to implement matchers for all json providers itself or it is only responsible to delegate requests, eg: from JsonPathMatchers.arrayContaining()
to JsonSmartMatchers.arrayContaining()
🤔
For me, I think JsonSmart should implement its matchers itself.
Then I can use JsonSmartMatchers
in unit test cases before JsonPathMatchers
to adapt all providers' implementation.
I've found a existing json matchers facade https://github.com/Crunc/hamcrest-json-matchers , but it does not support JsonSmart now, nor support making assertion on json array element. 😢
Story
Spring MVC's
MockMvcResultMatchers#jsonPath()
usescom.jayway.jsonpath.JsonPath
to evaluate string content into objects, and JsonPath usesJsonSmartJsonProvider
by default, when a developer attempt to do an unit test like below, there is no suitable helper methods he/she can use:Expected solution
Provide some org.hamcrest.Matcher helpers like
Matchers.arrayContaining()
?Related documents