Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Question: Single vs Multiple coverage.xml files #34

@kenjones-cisco

Description

@kenjones-cisco

Description

In the README I noticed the following section:

You must end-up with one coverage file per directory:

pkg1/coverage.xml
pkg2/coverage.xml
pkg3/coverage.xml
...

Currently I'm able to generate a single coverage.xml file for an entire project with multiple packages within the same project. And cobertura within Jenkins is able to read and process the file and show all of the packages.

Example single coverage.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-03.dtd">
<coverage line-rate="0" branch-rate="0" version="" timestamp="1506622955562">
	<sources>
		<source>/usr/local/go/src</source>
		<source>/go/src</source>
		<source>/authlib/src</source>
	</sources>
	<packages>
		<package name="gitscm.cisco.com/ccdev/authlib/authz" line-rate="0" branch-rate="0" complexity="0">
			<classes>
				<class name="-" filename="gitscm.cisco.com/ccdev/authlib/authz/context.go" line-rate="0" branch-rate="0" complexity="0">
					<methods>
						<method name="key" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="11" hits="11"></line>
							</lines>
						</method>
						<method name="GetUsername" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="16" hits="6"></line>
								<line number="17" hits="5"></line>
								<line number="19" hits="1"></line>
							</lines>
						</method>
						<method name="SetUsername" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="24" hits="5"></line>
							</lines>
						</method>
					</methods>
					<lines>
						<line number="11" hits="11"></line>
						<line number="16" hits="6"></line>
						<line number="17" hits="5"></line>
						<line number="19" hits="1"></line>
						<line number="24" hits="5"></line>
					</lines>
				</class>
			</classes>
		</package>
		<package name="gitscm.cisco.com/ccdev/authlib/authz/casbin" line-rate="0" branch-rate="0" complexity="0">
			<classes>
				<class name="-" filename="gitscm.cisco.com/ccdev/authlib/authz/casbin/ldap_role_manager.go" line-rate="0" branch-rate="0" complexity="0">
					<methods>
						<method name="CheckLdapEnv" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="32" hits="4"></line>
								<line number="33" hits="1"></line>
								<line number="35" hits="3"></line>
								<line number="36" hits="1"></line>
								<line number="38" hits="2"></line>
								<line number="39" hits="1"></line>
								<line number="41" hits="1"></line>
							</lines>
						</method>
						<method name="LDAPRoleManager" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="46" hits="1"></line>
							</lines>
						</method>
						<method name="@46:9" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="47" hits="1"></line>
								<line number="48" hits="1"></line>
								<line number="49" hits="1"></line>
								<line number="50" hits="1"></line>
								<line number="53" hits="1"></line>
								<line number="54" hits="1"></line>
								<line number="56" hits="1"></line>
							</lines>
						</method>
						<method name="NewLdapRoleManager" signature="" line-rate="0" branch-rate="0">
							<lines>
								<line number="62" hits="2"></line>
								<line number="70" hits="2"></line>
								<line number="71" hits="2"></line>
								<line number="72" hits="1"></line>
								<line number="74" hits="1"></line>
								<line number="78" hits="1"></line>
							</lines>
						</method>
					</methods>
					<lines>
						<line number="32" hits="4"></line>
						<line number="33" hits="1"></line>
						<line number="35" hits="3"></line>
						<line number="36" hits="1"></line>
						<line number="38" hits="2"></line>
						<line number="39" hits="1"></line>
						<line number="41" hits="1"></line>
						<line number="46" hits="1"></line>
						<line number="47" hits="1"></line>
						<line number="48" hits="1"></line>
						<line number="49" hits="1"></line>
						<line number="50" hits="1"></line>
						<line number="53" hits="1"></line>
						<line number="54" hits="1"></line>
						<line number="56" hits="1"></line>
						<line number="62" hits="2"></line>
						<line number="70" hits="2"></line>
						<line number="71" hits="2"></line>
						<line number="72" hits="1"></line>
						<line number="74" hits="1"></line>
						<line number="78" hits="1"></line>
					</lines>
				</class>
			</classes>
		</package>
	</packages>
</coverage>
  1. Is there a technical limitation within SonarQube that requires the coverage to be done as one coverage.xml per package? Or is this rule imposed by the plugin?

  2. As a follow up, does the coverage.xml have to be in the same directory as the code? Or is it possible to leverage a cover directory that has a directory for each package and the coverage.xml file exists within that directory?

Example Directory structure for coverage:

cover/
    github.com/org/repo/pkg1/coverage.xml
    github.com/org/repo/pkg2/coverage.xml
    github.com/org/repo/pkg3/coverage.xml
    ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions