JUnit 5 Architecture. Part 2
3. JUnit 5 Jupiter
JUnit Jupiter is the combination of the new programming model (annotations, classes, methods) and extension model for writing tests and extensions in JUnit 5. The Jupiter sub-project provides a TestEngine for running Jupiter based tests on the platform. In contrast to the previously existing runners and rules extension points in JUnit 4, the JUnit Jupiter extension model consists of a single, coherent concept: the Extension API.
The artifacts contained into the JUnit Jupiter are:
- junit-jupiter-api, the JUnit Jupiter API for writing tests and extensions.
- junit-jupiter-engine, the JUnit Jupiter test engine implementation, only required at runtime.
- junit-jupiter-params, which provides support for parameterized tests in JUnit Jupiter.
- junit-jupiter-migrationsupport, which provides migration support from JUnit 4 to JUnit Jupiter, and it’s required only for running selected JUnit 4 rules.
4. JUnit 5 Vintage
JUnit Vintage provides a TestEngine for running JUnit 3 and JUnit 4 based tests on the platform. JUnit 5 Vintage only contains junit-vintage-engine, the engine implementation to execute tests written in JUnit 3 or 4. For this you also need the JUnit 3 or 4 JARs.
This is useful in order to interact with the old tests through JUnit 5. It’s likely that you may need to work on your projects with JUnit 5, but still support many old tests. JUnit 5 Vintage is the solution for this situation!
5. The big picture of the JUnit 5 architecture
To put everything head to head and show how the full architecture works, we’ll say that JUnit Platform provides the facilities to run different kinds of tests: JUnit 5 tests, old JUnit 3 and 4 tests, third-party tests (figure 2).
Figure 2 The big picture of the JUnit 5 architecture.
In more detail (figure 3):
- The test APIs provide the facilities for different test engines: junit-jupiter-api for JUnit 5 tests; junit-4.12 for legacy tests; custom engines for third-party tests.
- The test engines mentioned above are created by extending the junit-platform-engine public API, part of the JUnit 5 Platform.
- The junit-platform-launcher public API provide the facilities to discover tests inside the JUnit 5 Platform, for build tools like Maven or Gradle or for IDEs.
Figure 3 The detailed picture of the JUnit 5 architecture.
Besides the modular architecture, JUnit 5 also provides the extensions mechanism.
We underline the fact that the architecture of a system strongly determines its capabilities and its behavior. Understanding the architecture of both JUnit 4 and JUnit 5 helps you easily apply their capabilities in practice, write efficient tests, and analyze the implementation alternatives. They help you fasten the pace at which you gain the skills of a programmer who masters unit testing.
Interested in Java? Check out our trainings.
Java and Web Technologies Expert