junit.framework.AssertionFailedError: No tests fou

2019-02-24 23:24发布

问题:

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>

回答1:

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.