Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.4.0
-
Reviewed
Description
The updateTestDataAutomatically helper function should have a fix json format to be useful.
String actual = json.toString(2);
updateTestDataAutomatically(expectedResourceFilename, actual);
assertEquals(
prettyPrintJson(getResourceAsString(expectedResourceFilename)),
prettyPrintJson(actual));
The comparison is working with different json formats which is all right, but updating the test data should be easy, and the git diff should be easily readable by humans.
Something like this could work:
String actual = prettyPrintJson(json.toString(2));
updateTestDataAutomatically(expectedResourceFilename, actual);
assertEquals(
getResourceAsString(expectedResourceFilename),
actual);
The json's must be updated unfortunately with the new format.
The defaults shouldn't change here. Maybe we should be even more explicit with the format options:
private static String prettyPrintJson(String in) throws JsonProcessingException { ObjectMapper objectMapper = new ObjectMapper(); return objectMapper .writerWithDefaultPrettyPrinter() .writeValueAsString(objectMapper.readTree(in)); }
Attachments
Issue Links
- links to