How to set the working directory for the <junit> task to something other than based on?

I have an Ant script with a target junit where I want it to start a virtual machine with a different working directory than based on. How should I do it?

Here's a pseudo version of my goal.

<target name="buildWithClassFiles">
    <mkdir dir="${basedir}/UnitTest/junit-reports"/>
    <junit fork="true" printsummary="yes">
        <classpath>
            <pathelement location="${basedir}/UnitTest/bin"/>
            <path refid="classpath.compile.tests.nojars"/>
        </classpath>
        <jvmarg value="-javaagent:${lib}/jmockit/jmockit.jar=coverage=:html"/>
        <formatter type="xml" />
        <test name="GlobalTests" todir="${basedir}/UnitTest/junit-reports" />
    </junit>

</target>
+3
source share
2 answers

You tried:

 <junit fork="true" printsummary="yes" dir="workingdir">
+6
source

I think other answers may not take into account the fact that you want to specify a working directory, and not just that you want to run junit in a specific directory. In other words, you want to make sure that if the test creates a file without path information, this is from the base directory that you specify.

, JVM arg junit, user.dir:

 <junit fork="true" ...>
   <jvmarg value="-Duser.dir=${desired.current.dir}"/>
    ....
0

Source: https://habr.com/ru/post/1698922/


All Articles