Writing your own JUnit extensions using @Rule

The @Rule annotation allows you to annotate a public field in your test class, which is of type MethodRule. This binding will intercept test method calls like an AOP framework would do and redefine the execution, skip it, or do anything else.
In example, suppose you want to run some concurrency test: you may need to execute your test method on 15 threads each starting at the same time, and then wait for all threads to finish. For those knowing TestNG, this is equivalent to the attribute parallel of @Test.
This blog article shows you through this example how to implement this feature in Junit with a quick Junit extensions.
Mathieu