3

I am getting this error when I try to run Junits from ANT task. using eclipse launcher it works fine. Version of junit is 4.9 and ANT version is 1.7 Surprisingly its giving "junit.framework.AssertionFailedError" which was package structure in JUNIT 3., in 4 it has changed to org.junit. I cross checked all libs and there is NO reference of junit 3.* version --and its working anyway using eclipse launcher. Any clue? Let me know if more detail is needed. Ant task is as follows

<target name="test">
  <junit fork="yes" haltonfailure="yes">
    <test name="${test.class.name}" />
    <formatter type="plain" usefile="false" />
    <classpath refid="junittest.classpath" />
  </junit>
</target>
cpandey05
  • 1,241
  • 2
  • 17
  • 30

1 Answers1

3

You should check, which junit.jar and ant-junit.jar ant is trying to use and make sure, they are for JUnit 4. Take a look at http://ant.apache.org/manual/Tasks/junit.html for the best place to put them.

nfechner
  • 17,295
  • 7
  • 45
  • 64
  • Thanks a lot for the ponter, ant-junit.jar was out of sync, it was 1.6.2 – cpandey05 Sep 20 '11 at 10:29
  • 1
    Just to add: if using JUnit4, the corresponding ant-junit JAR file is `ANT_HOME/lib/ant-junit4.jar`. If we miss the 4 and use `ANT_HOME/lib/ant-junit.jar` then we get this error: `junit.framework.AssertionFailedError: No tests found` (This is ant version 1.9.4 which has both `ant-junit.jar` and `ant-junit4.jar`) – arun Aug 31 '14 at 23:14