Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cobertura reporter does not construct package name attributes from projectRoot #552

Open
tsondergaard opened this issue Apr 4, 2020 · 1 comment

Comments

@tsondergaard
Copy link

The image below shows an excerpt of a coverage report displayed by the jenkins CI cobertura plugin for a project that is mostly implemented in C++, but which has a component written in TypeScript running in node that is tested with jest using the istanbul cobertura coverage reporter. In the picture "sparrow" is the name of a component written in C++. The "src", "src.controller", "src.db", etc packages are all from the node subproject. My issue is that these packages don't have the subproject name prefixed.

image

I pass a projectRoot config property to jest which istanbul-reports/lib/cobertura/index.js uses for filepaths, but not for package names. This is what is generated:

<?xml version="1.0" ?>
<!DOCTYPE coverage SYSTEM "http://cobertura.sourceforge.net/xml/coverage-04.dtd">
<coverage lines-valid="3046" lines-covered="1582" line-rate="0.5194" branches-valid="1355" branches-covered="531" branch-rate="0.39189999999999997" timestamp="1586032913784" complexity="0" version="0.1">
  <sources>
    <source>/home/foo/src/main-project</source>
  </sources>
  <packages>
    <package name="src" line-rate="0.7398" branch-rate="0.2386">
      <classes>
        <class name="app.ts" filename="sub-project/src/app.ts" line-rate="0.8934000000000001" branch-rate="0.16">
         ....

The problem is the package attribute name="src" it should be name="sub-project.src" to be consistent with the projectRoot and match the path in the class filename="sub-project/src/app.ts" attribute.

@bitcloud
Copy link
Contributor

I don't think that this issue can bis solved in the cobertura reporter as it depends on getRelativeName from SummarizerFactory.

SummarizerFactory try's to detect the project root by automatically detecting a common base directory.

/project/src/package1/subpackage1/index.js
/project/src/package1/subpackage2/index.js
----
commonParent => /project/src/package1

I guess SummarizerFactory needs to be projectRoot aware to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants