Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用ant在两个JVM中并行运行junits_Java_Ant_Junit - Fatal编程技术网

Java 使用ant在两个JVM中并行运行junits

Java 使用ant在两个JVM中并行运行junits,java,ant,junit,Java,Ant,Junit,我有大量的junits,运行它们需要很长时间。但是CPU和内存的利用率只有30%左右。我不能在同一jvm中的并行线程中运行junits,因为它们不是线程安全的,而且不可能修复它们。 据我所知,junit ant任务启动单独的jvm来运行junits。 可以从ant为junits运行几个JVM吗?我认为这样的解决方案可以显著减少执行时间 目前,我使用以下代码与ant一起运行它们: <for param="bundle" keepgoing="true"> <path>

我有大量的junits,运行它们需要很长时间。但是CPU和内存的利用率只有30%左右。我不能在同一jvm中的并行线程中运行junits,因为它们不是线程安全的,而且不可能修复它们。 据我所知,junit ant任务启动单独的jvm来运行junits。 可以从ant为junits运行几个JVM吗?我认为这样的解决方案可以显著减少执行时间

目前,我使用以下代码与ant一起运行它们:

<for param="bundle" keepgoing="true">
<path>
    <dirset dir="${testdir}/plugins">
        <depth max="0"/>
    </dirset>
</path>
<sequential>

    <echo message="Running tests in bundle @{bundle}"/>
    <junit outputtoformatters="no" printsummary="yes" failureproperty="test.failed" maxmemory="512m" fork="yes"  forkmode="once">
        <classpath>
            <path refid="tests.classpath" />
        </classpath>

        <formatter type="xml" />
        <batchtest todir="${junit.result.dir}">
            <fileset dir="@{bundle}/src">
                <patternset refid="test.sources" />
            </fileset>
        </batchtest>
    </junit>
</sequential>

看看这个

的主要用例是运行外部程序,例如 作为应用服务器,JUnit或TestNG测试套件 同时。任何试图并行运行大型Ant任务序列的人, 例如javadoc和javac同时出现,是隐式的 识别和修复所有并发错误的任务 他们跑

哪个有这个例子

<parallel>
  <wlrun ... >
  <sequential>
    <sleep seconds="30"/>
    <junit fork="true" forkmode="perTest" ... >
    <wlstop/>
  </sequential>
</parallel>


编辑:更新的forkmode设置

描述了您的目标吗?文档中说并行是通过线程实现的,对吗?这是否与askers请求冲突?线程用于启动JUNIT Ant任务,而JUNIT Ant任务又被配置为启动单独的JVM实例。这就是fork=“true”的用途。