I have used snapshots for a while with jest and I'm really glad this library exists for Java. Snapshot-based assertions are very useful to make sure a data-processing system is consistently producing the correct output for a given input.
One of the most useful features of snapshots is being able to quickly spot when a specific value within a large payload has changed. Therefore, the output format matters a lot. However, JSON isn't always the most human-friendly format as it can be verbose with a lot of braces and commas that only get in the way.
So when I setup this library up in a new project of mine I wrote a custom serializer based on YAML, which I found to be the most clean and visually readable format among the common standard formats out there.
I think it could be a good addition having this shipped along with the jackson plugin.
I'd be happy for this to be added to java-snapshot-testing-jackson as an additional Serializer. Would you consider a PR?
Some comments:
Probably don't want to convert to a list by defaultArrays.asList(object);, rather - the client can do that if they want it.
Surround with [ & ] to make consistent with String Serailizer (and avoid the bug you reported). This however does make it look a little to JSON like. The alternative is to trip the trailing new lines.
I have used snapshots for a while with jest and I'm really glad this library exists for Java. Snapshot-based assertions are very useful to make sure a data-processing system is consistently producing the correct output for a given input.
One of the most useful features of snapshots is being able to quickly spot when a specific value within a large payload has changed. Therefore, the output format matters a lot. However, JSON isn't always the most human-friendly format as it can be verbose with a lot of braces and commas that only get in the way.
So when I setup this library up in a new project of mine I wrote a custom serializer based on YAML, which I found to be the most clean and visually readable format among the common standard formats out there.
I think it could be a good addition having this shipped along with the jackson plugin.
Here's the code I came up with:
A sample snapshot making use of that serializer looks like this: