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 the SpringJUnit4ClassRunner
Runner. The Spring Runner then handles the @ContextConfiguration
Annotation.
So it works, no matter if you start the test from Eclipse, an ohter IDE, command line, Maven or Ant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With