There is one thing i know about unit tests, they should be concise, easy to read, easy to maintain, and they should easily give you an idea about what the library does !
the idea is Given an annotated DTO, we generate the ui Form, then we inspect the ui form to make sure that none of the informations specified in the annotations are missing.
There is 2 alternatives for this:
Either use the UI Form pojo:
The JsonSchema object to test the customized json schema, and the JsonNode object to test the json schema ui form.
It is easy to fetch information from the JsonSchema object to make assertions, but the problem resides in the JsonNode object, it has a tree-like structure, and traversing trees often results in a complex code that is harder to maintain in the long run, and the more complex the json it represents, the more harder it will become to fetch an information out of it.
Or Serialize the ui form to json, and use Domain specific language (DSL) to query the json for the wanted information:
I found a quite popular library named json path, it has a query language like SQL to query json. the syntax is pretty easy to grasp. It also comes with helper classes for unit tests, to traverse json and make assertions.
Coverage increased (+85.8%) to 85.789% when pulling 3efac63fcc8b9f5409ffce0362dea2c271c0212d on Hdebbech:master into 09ed590af0f3d35e66aef4c9839e3bd4f049aad0 on JsonSchema-JavaUI:master.
Coverage increased (+85.8%) to 85.789% when pulling 6ae2f4fe5350c2f3cad30b3f516286e7b377524e on Hdebbech:master into 09ed590af0f3d35e66aef4c9839e3bd4f049aad0 on JsonSchema-JavaUI:master.
Added test cases for these layouts
These will cover around 86 % of the code
Testing strategy :
There is one thing i know about unit tests, they should be concise, easy to read, easy to maintain, and they should easily give you an idea about what the library does !
the idea is Given an annotated DTO, we generate the ui Form, then we inspect the ui form to make sure that none of the informations specified in the annotations are missing.
There is 2 alternatives for this: