Google's compile-testing is a great tool when it comes to unit testing annotation processors. Unfortunately I'm currently facing the following error:
java.lang.AssertionError:
An expected source declared one or more top-level types that were not present.
Expected top-level types: <[test.LocalStorage]>
Declared by expected file: <LocalStorageImpl.java>
The top-level types that were present are as follows:
- [test.LocalStorageImpl] in </SOURCE_OUTPUT/test/LocalStorageImpl.java>
My processor generates the implementation of an annotated interface. So the generated code has a dependency to the interface (class LocalStorageImpl implements LocalStorage).
When I try to verify the generated code with
JavaFileObject source = /* interface definition */
JavaFileObject expected_source = /* the generated implementation */
assertAbout(javaSource()).that(source)
.processedWith(new MyProcessor())
.compilesWithoutError()
.and()
.generatesSources(expectedSource);
...the generatesSource causes the error. As the error message states, it cannot resolve the interface definition.
So my question is how to compile or write the source file of the interface defined in source, so that it is recognized by generatesSources()?
Aucun commentaire:
Enregistrer un commentaire