Running junit4 tests with ant 1.9.4 (jvm crash with fork=“true”)

I'm trying to run junit 3 and junit 4 tests with ant 1.9.4 With fork="true" in the junit task I experience strange errors (jvm) crash:

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.

When I run the unit tests with fork="false" there is no problem. The ant task looks as follows

<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>

It doesn't work without the jvm attribute either. test.classpath seems to be correctly filled with junit 4, too.

The problem is independent of the code in the unit tests: even if the tests contains only assertEquals(true, true) the jvm crashes. The jvm doesn't write a crash file. When I run the jvm with flightrecorder there is a deadlock and it never terminates until the junit ant task timeout is reached.

Remote debugging didn't work either, the jvm running the test will terminate as soon as a debugger connects.

Basically I played with all of the parameters available in the junit ant task and none of them worked (showoutput="true"/"false" clonevm="true"/"false" etc..)

In similar questions on stackoverflow it is suggested that a System.exit() or OutOfMemoryException could cause the problem, but this is definitely not the case here.

Running junit 4 tests with ant should work without problems out of the box - anybody an idea what could be the problem here?


问题在于(非常长的)类路径中有一个老版本的ant对神秘地造成JVM崩溃的旧ant贡献。

链接地址: http://www.djcxy.com/p/86092.html

上一篇: 为什么“ant junit”没有找到测试套件

下一篇: 用ant 1.9.4运行junit4测试(jvm crash with fork =“true”)