【问题标题】:junit.framework.AssertionFailedError: No tests found in xyz packagejunit.framework.AssertionFailedError:在 xyz 包中找不到测试
【发布时间】:2011-09-20 02:05:34
【问题描述】:

当我尝试从 ANT 任务运行 Junits 时出现此错误。使用 eclipse 启动器它工作正常。 junit的版本是4.9,ANT版本是1.7 令人惊讶的是,它给出了“junit.framework.AssertionFailedError”,这是 JUNIT 3. 中的包结构,在 4 中它已更改为 org.junit。 我交叉检查了所有库,没有 junit 3.* 版本的参考——而且它仍然可以使用 eclipse 启动器工作。 有什么线索吗?让我知道是否需要更多细节。 Ant任务如下

<target name="test">
  <junit fork="yes" haltonfailure="yes">
    <test name="${test.class.name}" />
    <formatter type="plain" usefile="false" />
    <classpath refid="junittest.classpath" />
  </junit>
</target>

【问题讨论】:

    标签: eclipse ant junit4


    【解决方案1】:

    您应该检查 junit.jarant-junit.jar ant 正在尝试使用哪个,并确保它们适用于 JUnit 4。查看 http://ant.apache.org/manual/Tasks/junit.html 以获得放置它们的最佳位置。

    【讨论】:

    • 非常感谢 ponter,ant-junit.jar 不同步,它是 1.6.2
    • 补充一点:如果使用JUnit4,对应的ant-junit JAR文件为ANT_HOME/lib/ant-junit4.jar。如果我们错过了 4 并使用了ANT_HOME/lib/ant-junit.jar,那么我们会得到这个错误:junit.framework.AssertionFailedError: No tests found(这是 ant 版本 1.9.4,它同时具有 ant-junit.jarant-junit4.jar
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 2019-10-26
    相关资源
    最近更新 更多