What is rule in unit test?

What exactly is a rule in a JUnit test?

JUnit rules interrupt the test method and enable us to perform anything before and after the test method has been performed. For example, we can specify the timeout for all tests using the @Timeout rule.