gpt4 book ai didi

java - fork JUNIT 执行

转载 作者:行者123 更新时间:2023-11-30 07:23:27 25 4
gpt4 key购买 nike

今天我已经为此苦苦挣扎了一段时间。不知道是否有人可以帮忙

目标尝试减少 JUnit 执行时间。我正在尝试分出 5 个虚拟机,每个虚拟机都提供一个容器来执行测试子集。我相信我的机器上有足够的内存(5 个虚拟机 * 每个 3G = 15GB)来处理负载。

我正在尝试使用 forkmode="perBatch"模式。但是,通过下面的 ANT 文件,我无法看到 5 个虚拟机被 fork 。 JUnit 测试也不是并行执行的。

我哪里出错了?

   <target name="runTestSuite" depends="JunitTestsCompile">
<junit printsummary="yes" haltonfailure="no" failureProperty="runTestSuite.failure" showoutput="false" fork="true" forkmode="perBatch">
<jvmarg value="-XX:MaxPermSize=3072M"/>
<jvmarg value="-Xms3072M"/>
<jvmarg value="-XX:+UseParallelGC"/>
<jvmarg value="-server"/>
<jvmarg value="-Xmx3072M"/>
<jvmarg value="-XX:-UseSplitVerifier"/>
<jvmarg value="-Djavax.xml.parsers.XmlDocumentParserFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl" />
<formatter type="xml" />

<classpath location="${instrumented.dir}" />
<classpath location="${classes.dir}" />
<classpath>
<path refid="junit.classpath"/>
<pathelement location="${build.dir}"/>
<pathelement location="${src.main.dir}/project/properties"/>
<pathelement location="${src.main.dir}/build/svr/cls"/>
<pathelement location="${src.main.dir}"/>
<pathelement location="${src.aspects.dir}"/>
<pathelement location="${lib.dir}/junit.jar"/>
</classpath>

<!-- Execute all tests -->
<batchtest todir="${junit.log.dir}">
<fileset dir="${build.dir}" >
<include name="my/org/whatever/something/abc/myTest.class"/>
</fileset>
</batchtest>
<batchtest todir="${junit.log.dir}">
<fileset dir="${build.dir}" >
<include name="my/org/whatever/something/abc/myTest2.class"/>
</fileset>
</batchtest>

<batchtest todir="${junit.log.dir}">
<fileset dir="${build.dir}" >
<include name="my/org/whatever/something/abc/myTest3.class"/>
</fileset>
</batchtest>

<batchtest todir="${junit.log.dir}">
<fileset dir="${build.dir}" >
<include name="my/org/whatever/something/abc/myTest4.class"/>
</fileset>
</batchtest>

<batchtest todir="${junit.log.dir}">
<fileset dir="${build.dir}" >
<include name="my/org/whatever/something/abc/myTest5.class"/>
</fileset>
</batchtest>

最佳答案

在这方面花费了更多时间后,我发现 JVM fork 只会分出一个新的 JVM,而不一定是并行的。如果我们想要并行 Junits,我们最好使用 ANT 并行结构。

关于java - fork JUNIT 执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37151983/

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