concept JUnit 5 extension model in category java

appears as: JUnit 5 extension model
JUnit in Action

This is an excerpt from Manning's book JUnit in Action.

Table 4.1 Migrating from JUnit 4 and JUnit 5

Main step

Comments

Replace the needed dependencies

JUnit 4 needs a single dependency. JUnit 5 requires more dependencies, related to the features that are used. JUnit 5 uses JUnit Vintage to work with old JUnit 4 tests.

Replace the annotations, and introduce the new ones

Some JUnit 5 annotations mirror the old JUnit 4 ones. Some new ones introduce new facilities and help developers write better tests.

Replace the testing classes and methods

JUnit 5 assertions and assumptions have been moved to different classes from different packages.

Replace the JUnit 4 rules and runners with the JUnit 5 extension model

This step generally requires more effort than the other steps in this table. Because JUnit 4 and JUnit 5 may coexist for a long period, however, the rules and runners may remain in the code or be replaced much later.

14.1  Introducing the JUnit 5 extension model

Although JUnit 4 provides extension points through runners and rules (see chapter 3), the JUnit 5 extension model consists of a single concept: the Extension API. Extension itself is just a marker interface (or tag or token interface)—an interface with no fields or methods inside. It is used to mark the fact that the class implementing an interface of this category has some special behavior. Among the best-known Java marker interfaces are Serializable and Cloneable.