mardi 30 août 2016

How to test java code (the source itself)

I have two files in my maven project which belong to each other. One is java code in src/main/java, the other is a json file in src/main/resources folder.

I want to make sure that if a property is added or updated in the Java code, that also the according json file is updated and vice versa. My idea is to write a unit test which fails in such cases.

For most properties I could scan the java code using reflection, but when it comes to generics (for example a property of type List<Foo>) I'm stuck because even reflection does not know about Foo.

So my idea is to parse the java source itself. I've never done this before and don't know what to search for.

Aucun commentaire:

Enregistrer un commentaire