A Java library for testing javac compilation and annotation processors in unit tests.
Compile Testing is a Java library that provides tools for testing javac compilation and annotation processors within unit tests. It allows developers to programmatically compile Java source code and verify compilation outcomes, including success, failure, or specific diagnostic messages. This is particularly useful for testing custom annotation processors and ensuring compiler interactions behave as expected.
Java developers and library authors who create annotation processors, compiler plugins, or need to verify compilation behavior in their projects. It's especially valuable for those building Java tooling or frameworks that interact with the Java compiler.
Developers choose Compile Testing because it fills a gap in Java testing by providing a dedicated, programmatic way to test compilation scenarios that are difficult or impossible to test with standard unit testing frameworks. It's maintained by Google and integrates smoothly with existing Java testing workflows.
Testing tools for javac and annotation processors
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides a dedicated API for programmatically compiling Java code and asserting on diagnostics, as highlighted in the key features for compilation success, failure, and diagnostic inspection.
Specifically designed to test custom annotation processors by compiling code that uses them and verifying generated files, which is crucial for reliable tooling development as per the philosophy.
Maintained by Google with an Apache 2.0 license and active CI status, ensuring ongoing support and integration with modern Java testing workflows.
Allows creating and managing Java source files as strings within tests, eliminating the need for external files and simplifying test setup, as noted in the source file management feature.
The README is minimal and directs users to Javadoc for examples, which can increase the learning curve for new users unfamiliar with compiler testing APIs.
Limited to testing the standard javac compiler, so it cannot be used for alternative compilers or cross-compiler scenarios without significant workarounds.
Invoking the Java compiler within unit tests can be slower than standard testing, potentially impacting test suite execution times, especially for large or complex codebases.