Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ANT Cobertura

Status
Not open for further replies.

dexter195

Programmer
Jun 18, 2003
220
EU
Hi,

I have a few different projects that i need to run code coverage on using cobertura. Im testing this on two projects at the moment. I have it so that there are different folders for each report but the problem is, the classes from both projects are appearing in both of the seperate reports.
Is there a way around this?

Thanks for the help
Dexter


Code:
<!-- ========================================================== -->
<!-- Cobetura Code Coverage 									-->
<!-- ========================================================== -->


		<cobertura-instrument todir="${instrumented.classes.dir.OtherCar}">
			<fileset dir="${build.src.classes.dir.OtherCar}">
				<include name="**/*.class" />
				<exclude name="**/*Test*.class"/>
			</fileset>
		</cobertura-instrument>



		<cobertura-instrument todir="${instrumented.classes.dir.TestCar}">
			<fileset dir="${build.src.classes.dir.TestCar}">
				<include name="**/*.class" />
				<exclude name="**/*Test*.class"/>
			</fileset>
		</cobertura-instrument>




Code:
<!-- ========================================================== -->
<!-- JUnit Reporting - OtherCar				                    -->
<!-- ========================================================== -->

	<delete file="${root.dir}/coberturaOtherCar.ser"/>

	<target name="junit.OtherCar">
		<junit fork="yes" printsummary="yes">
	    	<sysproperty key="net.sourceforge.cobertura.datafile" file="${root.dir}/coberturaOtherCar.ser"/>
			<classpath location="${instrumented.classes.dir.OtherCar}"/>
			<classpath location="${build.test.classes.dir.OtherCar}"/>

			<classpath refid="cobertura.classpath"/>
			<classpath refid="test.classpath"/>


			<formatter type="xml"/>
	    	<batchtest fork="yes" todir="${test.reports.data.dir.OtherCar}">
	    		<fileset dir="${build.test.classes.dir.OtherCar}" includes="**/*Test*.class"/>
	    	</batchtest>
		</junit>

	<!--Create the JUnit Test Reports-->
    	<junitreport todir="${test.reports.data.dir.OtherCar}">
      		<fileset dir="${test.reports.data.dir.OtherCar}">
        		<include name="TEST-*.xml"/>
      		</fileset>
    	  	<report format="frames" todir="${test.reports.dir.junit.OtherCar}"/>
	    </junitreport>
	</target>

<!-- ========================================================== -->
<!-- Generating the Cobertura Test Report for OtherCar Module   -->
<!-- ========================================================== -->

	<cobertura-report format="html" destdir="${test.reports.dir.cobertura.OtherCar}" srcdir="${src.dir.OtherCar}"/>




<!-- ========================================================== -->
<!-- JUnit Reporting - TestCar				                    -->
<!-- ========================================================== -->
	<delete file="${root.dir}/coberturaTestCar.ser"/>
	
	<target name="junit.TestCar">
		<junit fork="yes" printsummary="yes">
	    	<sysproperty key="net.sourceforge.cobertura.datafile" file="${root.dir.TestCar}/coberturaTestCar.ser"/>
			<classpath location="${instrumented.classes.dir.TestCar}"/>
			<classpath location="${build.test.classes.dir.TestCar}"/>

			<classpath refid="cobertura.classpath"/>
			<classpath refid="test.classpath"/>

			<formatter type="xml"/>
	    	<batchtest fork="yes" todir="${test.reports.data.dir.TestCar}">
	    		<fileset dir="${build.test.classes.dir.TestCar}" includes="**/*Test*.class"/>
	    	</batchtest>
		</junit>

	<!--Create the JUnit Test Reports-->
    	<junitreport todir="${test.reports.data.dir.TestCar}">
      		<fileset dir="${test.reports.data.dir.TestCar}">
        		<include name="TEST-*.xml"/>
      		</fileset>
    	  	<report format="frames" todir="${test.reports.dir.junit.TestCar}"/>
	    </junitreport>
	</target>



<!-- ========================================================== -->
<!-- Generating the Cobertura Test Report				        -->
<!-- ========================================================== -->

	<cobertura-report format="html" destdir="${test.reports.dir.cobertura.TestCar}" srcdir="${src.dir.TestCar}"/>
 
I figured out what i was missing. In the Cobertura report tag i needed to specify the .ser file i wanted to use, otherwise it creates the cobertura.ser and combines all the classes in the other .ser files and these end up in all the reports.

Code:
<cobertura-report format="html" datafile="${root.dir}/coberturaTestCar.ser" destdir="${test.reports.dir.cobertura.TestCar}" srcdir="${src.dir.TestCar}"/>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top