【问题标题】:how to integrate junit in gwt project with the ant build file如何将 gwt 项目中的 junit 与 ant 构建文件集成
【发布时间】:2011-11-30 16:44:17
【问题描述】:

我有一个 gwt 项目,我想在我的项目中进行单元测试,所以我在 ant 构建文件中添加了 junit 的目标。但是构建总是失败,

BUILD FAILED C:\SG\workspace\app\build.xml:78: 如果不在 Ant 自己的类路径中,for 必须包含 junit.jar

这是脚本

<target name="test" depends="clean.test,gwtc" description="run all Junit tests">
    <mkdir dir ="test/test"/>
    **<junit fork = "false" printsummary = "yes"/>** <!-- the line 78-->
    <classpath refid = "project.class.path"/>
    <batchtest todir = "test/test">
        <fileset dir = "test" includes="**/${test}Test.java"/>
    </batchtest>
    <formatter type = "xml"/>
    <junitreport toDir = "test/test">
        <fileset dir = "test/test"/>
        <report format="frames" todir="test"/>
    </junitreport>
    <exec os="window" executable="cmd.exe">
        <arg line="-a /Applications/Safari.app test/index.html"/>
    </exec>
 </target>

【问题讨论】:

  • 您忘记添加脚本

标签: gwt ant


【解决方案1】:

你关闭&lt;junit /&gt;标签太早了。

这是正确的。 classpathbatchtestformatter 必须在 junit 标签内:

<junit fork = "false" printsummary = "yes">
    <classpath refid = "project.class.path"/>
    <batchtest todir = "test/test">
        <fileset dir = "test" includes="**/${test}Test.java"/>
    </batchtest>
    <formatter type = "xml"/>
</junit>

并且您必须确保 junit.jar 位于 ANT_HOME/lib 中,在 project.class.path 中引用或添加为另一个类路径,如 &lt;classpath refid = "junit.class.path"/&gt;

【讨论】:

  • 是的,我也找到了这些,非常感谢。此外,我添加了 ant-junit.jar。那么问题就解决了。
  • 很抱歉,我发现我目前没有足够的声誉来投票给您的答案。
  • @lhuang 你可以随时accept answers(当然如果你愿意)
猜你喜欢
  • 2013-04-20
  • 2012-01-02
  • 2011-01-10
  • 2018-08-08
  • 2011-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多