改变工作目录中的蚂蚁junit任务 [英] Change working directory in ant junit task

查看:172
本文介绍了改变工作目录中的蚂蚁junit任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个运行JUnits测试一个Ant文件。这些测试依赖于某些配置文件的相对路径。我试着设置了批量测试工作目录,但失败。

I have a ant file that runs JUnits tests. These tests rely on a relative path to certain configuration files. I've tried to set the working directory for the batch test, but fail.

我想要的工作目录是 $ {plugins.dir} / $ {名}

蚂蚁脚本的JUnit的一部分:

The JUnit part of the ant script:

<junit haltonfailure="no" printsummary="on" fork="true" showoutput="true" dir="${plugins.dir}/${name}">
    <jvmarg value="-Duser.dir=${plugins.dir}/${name}"/>
    <classpath> 
        <path refid="project.classpath"/>
        <pathelement location="${plugins.dir}/${dependency}/@dot/"/>
        <pathelement location="${plugins.dir}/${name}/" />
    </classpath>
    <formatter type="xml" />
    <sysproperty key="basedir" value="${plugins.dir}/${name}"/>
    <sysproperty key="dir" value="${plugins.dir}/${name}"/>
    <batchtest todir="${junit.output}">
        <fileset dir="${dir}"> 
            <include name="**\*AllTests.class" />
        </fileset>
    </batchtest>
</junit>

我GOOGLE了搜查,但我已经找到了解决方法已设置目录,sysproperty或jvmarg。正如你可以看到我已经试过所有:)

I've googled and searched but the workarounds I've found have been to set the "dir", "sysproperty" or "jvmarg". As you can see I've tried them all :)

有没有一种方法来打印标签中的当前目录?它不支持。这将允许我以验证目录实际上是改变到什么。

Is there a way to print the current dir in the tag? It doesnt support . That would allow me to verify if the dir is actually changed and to what.

在这个等式中一个通配符是,这是哈德森正在运行启动UPP启动antrunner日食过程。这是所以我们可以同时运行JUnit和Eclipse插件JUnit测试。应该不会有什么关系,我认为这个问题。

One wildcard in this equation is that this is being run in Hudson that starts upp an eclipse process that starts antrunner. This is so we can run both junit and eclipse plugin junit tests. Shouldn't have anything to do with the problem I think.

推荐答案

我认为你是对与中设置basedir属性(见的项目属性)。然而,由于它是ANT(而不是在JVM)的一个属性是只读!

I think you are right with setting the basedir property (see projects attributes). However, since it is a property of ANT (and not of the JVM) it is READ ONLY!

这是否影响其他目标,如果你呼唤你的Ant任务时设置的BASEDIR?请参见命令行参考

Does it effect other target if you set the basedir when calling your ant task? See Command Line reference.

ant -Dbasedir=somedir

另外,跨越一个新的蚂蚁进程调用您的JUnit目标。请参阅 AntCall任务或的 Ant任务。下面的例子假定JUnit的目标包含您的junit任务。我用这个任务的其他属性(永远需要BASEDIR属性为止。

Alternatively, span a new ant process to call your junit target. See the AntCall task or Ant task. Following examples assumes that the junit target contains your junit task. I used this task for other properties (never needed the basedir property so far.

<antcall target="junit">
  <param name="basedir" value="${plugins.dir}/${name}"/>
</antcall>

<ant dir="${plugins.dir}/${name}" target="junit" />

这篇关于改变工作目录中的蚂蚁junit任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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