Figure out our testing strategy

Description

Annotation processing is tricky to test: if the annotated types are part of our regular test sources, we can't test processor errors because they make the build fail. Also, we'll need a lot of different entities/DAOs to cover all the possible combinations of annotations, parameters, etc.

On the other hand, we could have the annotated types as non-source files, and fork an independent execution of javac. This will require a lot of boilerplate to set up the environment (classpath, etc.), and check the results (parse generated files, or try to run them?)

One third approach is to mock the Element / TypeMirror hierarchy and unit-test our generators.

This requires a bit of thought. We should also take a look at how other annotation-processing projects do it (Dagger, Android Room...)
We might end up with a combination of multiple approaches.

Environment

None

Pull Requests

None

Activity

Show:

Tomasz Lelek 
February 11, 2019 at 4:34 PM

I was looking at the annotation processing testing and found the `compile-testing` library:
https://github.com/google/compile-testing
Supposedly you can test annotation processing code in a fluent way:
https://stackoverflow.com/a/18620422/10447076

Fixed

Details

Assignee

Reporter

Fix versions

Reviewer

Priority

Created January 30, 2019 at 11:23 PM
Updated June 3, 2019 at 7:19 AM
Resolved April 24, 2019 at 8:54 PM