A rule is a utility class that provides some functionality that we can use again and again. JUnit 4 provides some utility rule classes for us.
https://junit.org/junit4/javadoc/4.12/org/junit/rules/TestRule.html
TempFolder
This rule lets us create temporary files in the system temporary folder that will get cleaned up once the tests have been run .
We add a public field to our test class and annotate it with "@Rule" .
Ex:
@Rule
public TemporaryFolder tmpFolder = new TemporaryFolder();
JUnit 5