gpt4 book ai didi

java - 如何设置 Ant 'junit' 任务的工作目录?

转载 作者:搜寻专家 更新时间:2023-10-30 21:03:39 25 4
gpt4 key购买 nike

我的 Ant 构建包括一个运行一些测试的 junit 任务。为了使测试正常进行,必须更改指定当前工作目录 (user.dir) 的属性值,但我不确定如何实现这一点。

有问题的任务目前看起来像这样:

<junit printsummary="withOutAndErr" fork="true"
haltonfailure="yes" showoutput="true"
filtertrace="false" dir="C:/workspace/obp-web">
<jvmarg value="-Duser.dir=C:/workspace/obp-web"/>

<classpath>
<fileset dir="${web.lib.dir}" includes="**/*.jar"/>
<fileset dir="${lib.dir}" includes="**/*.jar"/>
</classpath>
<batchtest fork="no" todir="${web.build.dir}/testresults">
<formatter type="xml"/>
<zipfileset src="${web.build.dir}/test-obp-web.jar">
<include name="**/*Test.class"/>
</zipfileset>
</batchtest>
</junit>

请注意,我已尝试使用“dir”属性和“jvmarg”任务将工作目录更改为 C:/workspace/obp-web。但是,当我在打开详细输出的情况下运行 Ant 时,我看到以下输出,这表明工作目录没有正确设置:

[junit] dir attribute ignored if running in the same VM

[junit] Using System properties {java.runtime.name=Java(TM) SE Runtime Environment, sun.boot.library.path=c:\jdk6\jre\bin, java.vm.version=10.0-b23, ant.lib rary.dir=C:\java\apache-ant-1.7.0\lib, java.vm.vendor=Sun Microsystems Inc., java.vendor.url=http://java.sun.com/, path.separator=;, java.vm.name=Java HotSpot(T M) Client VM, file.encoding.pkg=sun.io, user.country=CA, sun.java.launcher=SUN_STANDARD, sun.os.patch.level=Service Pack 1, java.vm.specification.name=Java Virtual Machine Specification, user.dir=c:\workspace\obp-ear, java.runtime.version=1.6.0_07-b06, java.awt.graphicsenv=sun.awt.Win32GraphicsEnvironment, java.endorse d.dirs=c:\jdk6\jre\lib\endorsed, os.arch=x86, java.io.tmpdir=C:\Users\donal\AppData\Local\Temp\, line.separator=

最佳答案

使用属性“dir”(也必须 fork 虚拟机):

http://ant.apache.org/manual/Tasks/junit.html

关于java - 如何设置 Ant 'junit' 任务的工作目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/466893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com