如何在Ant junit任务显示的类路径构建 [英] How to display the classpath build in an ANT Junit task

查看:218
本文介绍了如何在Ant junit任务显示的类路径构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经好几个月工作的蚂蚁junit任务突然与该用来发现类的NoClassDefFoundError失败。是否有显示是建立在junit任务类路径的方法吗?

 <目标名称=基本-的JUnit测试描述=运行单个JUnit测试。>    < JUnit的printsummary =是叉=NOhaltonfailure =YES>
        <&类路径GT;
            < pathelement位置=目标/ WEB-INF / lib中/的log4j-1.2.16.jar/>
            。
            。许多其他pathelements
            。
        < /类路径>
        <试验NAME =com.mycompany.command.TestUNLOCKACCOUNTCommandOUTFILE =$ {} report.dir / junit_test_results/>
    < / JUnit的>
< /目标与GT;


解决方案

我在我的构建上宣布我的ANT路径和使用中的各种任务的classpath引用的忠实粉丝。

pathconvert 任务可用于打印的classpath内容属性

 <路径ID =test.path>
    < pathelement位置=目标/ WEB-INF / lib中/的log4j-1.2.16.jar/>
    。
    。许多其他pathelements
    。
< /路径><目标名称=回声路径描述=回声测试路径>
    < pathconvert targetos =UNIX属性=test.path.unixREFID =test.path>
    <回声消息=测试路径:$ {} test.path.unix/>
< /目标与GT;<目标名称=基本-的JUnit测试取决于=回声路径描述=运行单个JUnit测试。>    < JUnit的printsummary =是叉=NOhaltonfailure =YES>
        <&类路径GT;
            <路径REFID =test.path/>
        < /类路径>
        <试验NAME =com.mycompany.command.TestUNLOCKACCOUNTCommandOUTFILE =$ {} report.dir / junit_test_results/>
    < / JUnit的>
< /目标与GT;

更新

刚刚发生,我...更简单的解决办法可能是在调试模式下运行ANT ....

An ANT junit task that has worked for months is suddenly failing with a NoClassDefFoundError for classes that used to be found. Is there a way to display the classpath that is built in the junit task?

<target name="basic-junit-test" description="Run a single JUnit test. ">

    <junit printsummary="yes" fork="no" haltonfailure="yes">
        <classpath>
            <pathelement location="target/WEB-INF/lib/log4j-1.2.16.jar"/> 
            .
            . many other pathelements
            .
        </classpath>
        <test name="com.mycompany.command.TestUNLOCKACCOUNTCommand" outfile="${report.dir}/junit_test_results" />
    </junit>
</target>

解决方案

I'm a big fan of declaring my ANT paths at the top of my build and using classpath references in the various tasks.

To pathconvert task can be used to print the classpath contents as a property:

<path id="test.path">
    <pathelement location="target/WEB-INF/lib/log4j-1.2.16.jar"/> 
    .
    . many other pathelements
    .
</path>

<target name="echo-path" description="Echo test path">
    <pathconvert targetos="unix" property="test.path.unix" refid="test.path">
    <echo message="Test path: ${test.path.unix}"/>
</target>

<target name="basic-junit-test" depends="echo-path" description="Run a single JUnit test. ">

    <junit printsummary="yes" fork="no" haltonfailure="yes">
        <classpath>
            <path refid="test.path"/>
        </classpath>
        <test name="com.mycompany.command.TestUNLOCKACCOUNTCommand" outfile="${report.dir}/junit_test_results" />
    </junit>
</target>

Update

Just occurred to me... An even simpler solution might be to run ANT in debug mode....

这篇关于如何在Ant junit任务显示的类路径构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆