Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I set the working directory for the Ant 'junit' task?
    text
    copied!<p>My Ant build includes a junit task that runs some tests. In order for the tests to work, the value of the property that specifies the current working directory (<code>user.dir</code>) must be changed, but I am unsure how to achieve this.</p> <p>The task in question currently looks like this:</p> <pre><code>&lt;junit printsummary="withOutAndErr" fork="true" haltonfailure="yes" showoutput="true" filtertrace="false" dir="C:/workspace/obp-web"&gt; &lt;jvmarg value="-Duser.dir=C:/workspace/obp-web"/&gt; &lt;classpath&gt; &lt;fileset dir="${web.lib.dir}" includes="**/*.jar"/&gt; &lt;fileset dir="${lib.dir}" includes="**/*.jar"/&gt; &lt;/classpath&gt; &lt;batchtest fork="no" todir="${web.build.dir}/testresults"&gt; &lt;formatter type="xml"/&gt; &lt;zipfileset src="${web.build.dir}/test-obp-web.jar"&gt; &lt;include name="**/*Test.class"/&gt; &lt;/zipfileset&gt; &lt;/batchtest&gt; &lt;/junit&gt; </code></pre> <p>Notice that I've tried to use both the "dir" attribute and the "jvmarg" task to change the working directory to C:/workspace/obp-web. However when I run Ant with verbose output turned on, I see the following output, which indicates that the working dir has not been set correctly:</p> <blockquote> <p><strong>[junit] dir attribute ignored if running in the same VM</strong></p> <p><strong>[junit] Using System properties</strong> {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=<a href="http://java.sun.com/" rel="noreferrer">http://java.sun.com/</a>, 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, <strong>user.dir=c:\workspace\obp-ear</strong>, 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=</p> </blockquote>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload