用ant 1.9.4运行junit4测试(jvm crash with fork =“true”)
我试图在junit任务中运行junit 3和junit 4测试1.9.4在junit任务中使用fork =“true”我遇到了奇怪的错误(jvm)崩溃:
12:40:58,686 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Testcase: testAdd took 0,005 sec
12:40:58,686 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Testcase: testAdd1 took 0 sec
12:40:58,755 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Testsuite: vai.testproduct.TestCalculator3
12:40:58,755 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0 sec
12:40:58,755 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO -
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Testcase: null took 0 sec
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Caused an ERROR
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run Tests@lnzvt-fls0010:80] INFO - [junit] junit.framework.AssertionFailedError: Forked Java VM exited abnormally. Please note the time in the report does not reflect the time until the VM exit.
当我用fork =“false”运行单元测试时,没有问题。 蚂蚁任务如下所示
<junit failureproperty="testCasesFailed" jvm="C:Program FilesJavajdk1.8.0_40binjava" fork="true" clonevm="true" showoutput="false" haltonfailure="false" haltonerror="false" timeout="600000" printsummary="true" includeantruntime="true">
<!-- NOTE timeout of 10 minutes-->
<jvmarg line="-Djava.awt.headless=true" />
<jvmarg value="-DbuildDate=${buildDate}" />
<jvmarg value="-XX:ErrorFile=./myfile%.txt" />
<jvmarg value="-XX:+PrintCommandLineFlags" />
<!--<jvmarg value="-XX:+UnlockCommercialFeatures"/>
<jvmarg value="-XX:+FlightRecorder" />
<jvmarg value="-XX:FlightRecorderOptions=dumponexit=true,defaultrecording=true,dumponexitpath=.,loglevel=info" />-->
<classpath refid="test.classpath" />
<formatter type="xml" />
<formatter type="plain" usefile="false" />
<batchtest todir="${tests.report.dir}">
<fileset dir="${target.tests.dir}" includes="${tests.includes}" excludes="${tests.excludes}" />
</batchtest>
</junit>
没有jvm属性,它也不起作用。 test.classpath似乎也正确填充了junit 4。
问题与单元测试中的代码无关:即使测试仅包含assertEquals(true,true),jvm也会崩溃。 jvm不写入崩溃文件。 当我使用flightrecorder运行jvm时,会出现死锁,并且在达到junit ant任务超时之前永远不会终止。
远程调试也不起作用,运行测试的jvm将在调试器连接后立即终止。
基本上我使用了junit ant任务中可用的所有参数,并且他们都没有工作(showoutput =“true”/“false”clonevm =“true”/“false”等。)
在类似的问题在stackoverflow它建议System.exit()或OutOfMemoryException可能会导致问题,但是这绝对不是这种情况。
运行junit与蚂蚁进行4次测试应该可以在没有问题的情况下工作 - 任何人都知道这里有什么问题?
问题在于(非常长的)类路径中有一个老版本的ant对神秘地造成JVM崩溃的旧ant贡献。
链接地址: http://www.djcxy.com/p/86091.html上一篇: Running junit4 tests with ant 1.9.4 (jvm crash with fork=“true”)