I am writing unit test cases for a project that will take JSON as post body and respond using JSON post body.
There are multiple checks to be made like:
- Are all mandatory fields specified?
- How is the system behaving with null values or field absence?
- How is the system behaving with null values in inner jsons?
- Boundary cases for numeric attributes.
For my initial set of unit test cases, I wrote multiple json's manually, store them as flat files and ran test cases. This will not scale out well for so many micro services.
So I want to achieve most of it using code. So in my initial phase I want to generate all permutation of json object given a skeleton. Like remove fields, make fields null, etc.
I am using Java 1.8, Jackson faster xml, jersey to achieve this. I am stuck at multiple fronts here:
- Since this is a very common use case, am I unaware any specific tool?
- Will Jackson JsonNode equals() method identify inequality with field value null or field absence.
- What could be the impact on inner json nodes?