I\'m experimenting with java annotation processors. I\'m able to write integration tests using the \"JavaCompiler\" (in fact I\'m using \"hickory\" at the moment). I can run the
I have used http://hg.netbeans.org/core-main/raw-file/default/openide.util.lookup/test/unit/src/org/openide/util/test/AnnotationProcessorTestUtils.java though this is based on java.io.File
for simplicity and so has the performance overhead you complain about.
Thomas's suggestion of mocking the whole JSR 269 environment would lead to a pure unit test. You might instead want to write more of an integration test which checks how your processor actually runs inside javac, giving more assurance it is correct, but merely want to avoid disk files. Doing this would require you to write a mock JavaFileManager
, which is unfortunately not as easy as it seems and I have no examples handy, but you should not need to mock other things like Element
interfaces.