I am trying to understand how @RunWith
can accept different types of Runners
. How does Junit understand or accept a different Runner and flex to run with a different runners (like SpringRunner , MockitoRunner), which are written by different vendors altogether.
The class must extend the abstract class Runner
.
From the javadoc
Element Detail
value
public abstract Class<? extends Runner> value
Returns:
a Runner class (must have a constructor that takes a single Class to run)
Any vendor can write a class which extends Runner
and Junit 4 can use it. Junit 4 depends only on the abstract class.