JUnit problem - java.lang.NoSuchMethodError: junit.framework.TestCase.getName()Ljava/lang/String;

 

Recently I switched to Junit 4.6 and started noticing the following error JUnit problem - java.lang.NoSuchMethodError: junit.framework.TestCase.getName()Ljava/lang/String; when JUnit tries to assert strings.

After looking at it more closely and googling a little I have found the cause of the problem. I am using dbUnit which in its own respect is dependant on JUnit and its dependency was lower version of JUnit that I was using which caused the above error.

In order to fix this issue you need to open build path and reaarange the jar depencies order to that JUnit jar is above all other jars like so:

Eclipse JUnit multi dependency problem

After doing so the assertion should work normally.

Enjoy :-)

This page was last updated on: 15/02/2010 09:28