Testing in the Modular World
The Java Platform Module System (JPMS) introduced with Java 9 poses new challenges when it comes to organizing and executing automated software tests. Finding tests and executing them via the reflection API is still possible but needs some extra configuration. JUnit 5 supports scanning for tests in modules since 5.1 and has a sample project that demonstrates three possible approaches.
The talk starts with a basic introduction to JUnit 5 and the Java module system before presenting the three approaches for executing tests when using the JPMS from the command line:
- Resorting to the class path
- Patching test binaries into main modules at runtime
- Patching main sources into test modules at compile time
It closes with an outlook:
- Are there variations or other approaches?
- How do build tools support you?
- What are best practices in IDEs?
Happy modular testing!