0
votes

I am trying to build a web application using Ant.

I am using JUnit and Cobertura for code coverage. Junit is only for DAO testing.

When i run build it compiles everything and before my JUnit runs i am calling cobertura.instrument which calls cobertura-instrument.

I am getting following error

[cobertura-instrument] The jvmargs attribute is deprecated. Please use nested jvmarg elements.
[cobertura-instrument] java.io.IOException: Cannot run program "C:\Program Files\Java\jdk1.6.0_24\jre\bin\java.exe": CreateProcess error=87, The parameter is incorrect
[cobertura-instrument]  at org.apache.tools.ant.taskdefs.Java.fork(Java.java:798)
[cobertura-instrument]  at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:214)
[cobertura-instrument]  at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:135)
[cobertura-instrument]  at net.sourceforge.cobertura.ant.InstrumentTask.execute(InstrumentTask.java:199)
[cobertura-instrument]  at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[cobertura-instrument]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[cobertura-instrument]  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[cobertura-instrument]  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[cobertura-instrument]  at java.lang.reflect.Method.invoke(Method.java:597)

I googled and found out it says

The maximum command line length for the CreateProcess function is 32767 characters. This limitation comes from the UNICODE_STRING structure

My Ant code for cobertura-instrument

<target name="coverage.instrument" depends="coverage.init,ztest.copy">
<delete file="${basedir}/cobertura.ser"/>
<cobertura-instrument todir="${coverage.instrument.dir}" maxmemory="1024M" datafile="${basedir}/cobertura.ser">
<fileset dir="${model.output.dir}">
<include name="**/*.class"/>
</fileset>
</cobertura-instrument>
</target>

I dont see any way that i can solve this.

Anyone help me in this issue ?

1
Pleas run ant with debug (-d) flag to see exactly what is being fed to java. - forty-two

1 Answers

0
votes

As an alternative to specifying each and every class file, which will be the result of a <fileset>, try using <instrumentationClasspath> as documented here: http://cobertura.sourceforge.net/anttaskreference.html. This would reduce the command line length considerably.