Cobertura Code Coverage Tool

  • Themenstarter Themenstarter Melly
  • Beginndatum Beginndatum
Status
Nicht offen für weitere Antworten.
M

Melly

Gast
Hallo,

ich werde das Code Coverage Tool Cobertura. Es liefert immer 100% Code Coverage. Kennt sich jemand damit aus oder weiß woran es liegen könnte?

Danke
 
Aus der FAQ: http://cobertura.sourceforge.net/faq.html
Usage

When I generate coverage reports, why do they always show 100% coverage everywhere?

When I generate coverage reports, why do they always show 0% coverage everywhere?

Cobertura is probably using the wrong .ser file when generating the reports. When you instrument your classes, Cobertura generates a .ser file containing basic information about each class. As your tests run, Cobertura adds additional information to this same data file. If the instrumented classes can not find the data file when running then they will create a new one. It is important that you use the same cobertura.ser file when instrumenting, running, and generating reports.

The best way to do this is to specify the location of the data file when running your tests. You should pass the -Dnet.sourceforge.cobertura.datafile=${basedir}/cobertura.ser sysproperty to the JUnit task.

Another common problem is that the cobertura.ser file is deleted, but the previously instrumented classes are not also deleted. Any time you delete your coverage data file you should also deleted all instrumented classes.
 
Hallo,

muss ich mit Tests laufen lassen? Kann ich nicht einfach mein Anwendung laufen lassen und nachsehen welche Code Stellen durchgelaufen sind?
 
Melly hat gesagt.:
Hallo,

muss ich mit Tests laufen lassen? Kann ich nicht einfach mein Anwendung laufen lassen und nachsehen welche Code Stellen durchgelaufen sind?
Machst du Witze??? :lol: :lol: :lol:

Das geht ausschliesslich bei Tests, genau darum geht es, herauszufinden wieviel, wie genau und welcher Code getestet wird(=Code Coverage).
 
Hallo,

ich habe es jetzt hinbekommen. Aber src file werden nicht angezeigt. Ich habe folgendes:


Code:
<property name="coveragereport.dir" value="codeCoverageReport" />
	<property name="src.dir" value="../" />
	<pathconvert pathsep="," property="javafiles" refid="src.files"/>

	<target name="coverage-report" >
		<delete dir="${coveragereport.dir}"/>
		<cobertura-report format="html" destdir="${coveragereport.dir}" maxmemory="1024M">
			<fileset dir="${src.dir}" id="src.files">
				<include name="**/*.java"/>
			</fileset>
		</cobertura-report>
	</target>

Warum funktioniert nicht so?
 
K.A., ich nutze das Cobertura Plugin für Maven 2, welches dann das Xref Plugin nutzt.
 
Status
Nicht offen für weitere Antworten.

Zurück
Oben