concept JUnit 4 rule in category java

This is an excerpt from Manning's book JUnit in Action MEAP V06.
A JUnit 4 rule is a component that intercepts test method calls; it allows us to do something before a test method is run and something else after a test method has run. Rules are specific to JUnit 4.
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.