I’m using Spring’s test annotations for the first time, and trying to understand how they fit togther. The doc says to use @RunWith to specify test runner and @ContextConfiguration to specify context config xml file. I want to run these tests through ant’s JUnit task.
I read that @RunWith is a JUnit annotation, so ant’s JUnit task should not have any problem processing it. But @ContextConfiguration is a Spring annotation, so how does JUnit process it? Or does Spring convert the test class into a subclass of JUnit TestCase and somehow specify the test runner? How do they actually work together?
By
@RunWith(SpringJUnit4ClassRunner.class)you tell JUnit to use an other Runner. In this case theSpringJUnit4ClassRunnerRunner. The Spring Runner then handles the@ContextConfigurationAnnotation.So it works, no matter if you start the test from Eclipse, an ohter IDE, command line, Maven or Ant.