2016-08-01 46 views
0

我試圖運行junit 3和junit 4測試用ant 1.9.4在junit任務中用fork =「true」我體驗奇怪的錯誤(jvm)崩潰:用ant 1.9.4運行junit4測試(jvm crash with fork =「true」)

12:40:58,686 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]:80] INFO - [junit] Testcase: testAdd took 0,005 sec 
12:40:58,686 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]:80] INFO - [junit] Testcase: testAdd1 took 0 sec 
12:40:58,755 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]:80] INFO - [junit] Testsuite: vai.testproduct.TestCalculator3 
12:40:58,755 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]: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 [email protected]:80] INFO - 
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]:80] INFO - [junit] Testcase: null took 0 sec 
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]:80] INFO - [junit]  Caused an ERROR 
12:40:58,756 [master>Build>Run and publish Unit Tests and Coverage>Run [email protected]: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 [email protected]: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 Files\Java\jdk1.8.0_40\bin\java" 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 =「真」 /「假」 clonevm =「真」 /「假」等。)

在類似的問題在stackoverflow它建議System.exit()或OutOfMemoryException可能會導致問題,但是這絕對不是這種情況。

運行junit與螞蟻4測試應該工作沒有問題開箱 - 任何人一個想法這裏可能是什麼問題?

回答

0

問題在於,在非常長的類路徑中,有一個老版本的ant在貢獻神祕地使JVM崩潰。

+0

嗨,你能否詳細說明一下貢獻是什麼?我有個類似的問題。 – jens