JUnit has an abstract implementation of @TestRule that lets you write a rule in a more simpler way. This is called ExternalResource and provides two protected methods that can be extended like this:
public class AwesomeTestRule extends ExternalResource {
@Override
protected void before() {
// do your magic
}
@Override
protected void after() {
// undo your magic, if needed
}
}