How to write automated unit tests for java annotation processor?

前端 未结 6 1455
遇见更好的自我
遇见更好的自我 2021-01-31 09:24

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

6条回答
  •  南旧
    南旧 (楼主)
    2021-01-31 09:54

    I was in a similar situation, so I created the Avatar library. It won't give you the performance of a pure unit test with no compilation, but if used correctly you shouldn't see much of a performance hit.

    Avatar lets you write a source file, annotate it, and convert it to elements in a unit test. This allows you to unit test methods and classes which consume Element objects, without manually invoking javac.

提交回复
热议问题