In almost any project that is using Spring, you get to the point where the Spring’s dependency injection mechanism is required also for unit tests. Combining this with JUnit leads one to the usage of the SpringJUnit4Runner to enable the initialization of the Spring context, as well as the autowiring of various beans in the test object that is just being executed.
However, for more specialized unit testing purposes, such as implementing parameterized tests or theories, one must use a specialized runner (Parameterized and Theories, respectively). This, of course, gets in conflict with Spring, which needs to use it’s own runner. JUnit does not support multiple runners for the same unit test (and except for the Spring runner, all the other runners are pretty excluding one another so it kind of makes sense to allow only one runner at a time). Read the rest of this entry »