Spring 2.5, Eclipse and JUnit 4.4

December 12 1 Comment Category: Eclipse, Java

SpringI tried to create JUnit tests for a Spring based project which I upgraded to the newest Spring version 2.5. The project is developed in Eclipse and I already got the JUnit4 library included in my Java Project:

JUnit4

To benefit from Spring JUnit support I had to add the following annotation to my test:

@RunWith(SpringJUnit4ClassRunner.class)

This caused a compilation error saying that the class org.junit.internal.runners.JUnit4ClassRunner was not found in my classpath but is needed internally from one of my imported classes (in my case SpringJUnit4ClassRunner)

I found out that JUnit 4.4 is needed to compile these new kind of Spring JUnit tests but the JUnit version bundled with Eclipse 3.3.x is 4.3:

JUnit 4.3

As this post states JUnit 4.4 will be included in the next milestone of Eclispe 3.4 – meanwhile I have to add it to my libraries manually.

Trackbacks/Pingbacks

  1. Climbing Back onto the Java Horse - January 22, 2009

    [...] bit of Googling, I worked out that I needed a newer version of JUnit than the one (v4.3.1) that came with Eclipse. [...]

Write a Comment

Commenter Gravatar