Announcement Announcement Module
No announcement yet.
How to execute tests with SpringJUnit4ClassRunner Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to execute tests with SpringJUnit4ClassRunner

    I read the chapter about testing in the manual with interest. What I'm trying to figure out is once I've annotated my tests, etc, how do I actually get them to execute using the SpringJUnit4ClassRunner?

    I just want them all to execute and get a report, but there was no example of this. Sorry if this is a dumb question, but the answer is non-obvious to me.

    Normally I would just use the ant JUnit task, but I'm not really sure what to do in this case, since a custom test runner is involved.

  • #2
    You still use junit(4) to run your tests, you just annotate them, e.g.:

    @ContextConfiguration(locations = {"classpath:spring/foo-beans.xml"})
    public class FooTest
    All this does is tell Junit to use the specified runner when it runs the tests.


    • #3

      I see, I've been using JUnit 3.8 too long, so I didn't realize that @RunWith was a JUnit 4annotation, I thought it was a Spring annotation, so I couldn't figure out what was kicking it all off in the first place.