Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change value of name column in cobertura report

I am using cobertura plugin in jenkins for code coverage. I want to change value of name column in Project Coverage summary on a per-report basis. enter image description here

Is there any way to change this. I want to give my project name over there.

like image 602
Prithvipal Singh Avatar asked Mar 21 '14 10:03

Prithvipal Singh


People also ask

What is cobertura code coverage?

Simply put, Cobertura is a reporting tool that calculates test coverage for a codebase – the percentage of branches/lines accessed by unit tests in a Java project.

How does cobertura generate code coverage reports?

1. Cobertura Code Coverage Report. Do nothing, just type the following Maven command to download and run the maven-cobertura-plugin automatically. Maven will generate the Cobertura code coverage report at ${project}/target/site/cobertura/index.


Video Answer


2 Answers

Here is a fork of the plugin that does what you are asking (project name instead of "cobertura coverage report").

https://github.com/andytompkins/cobertura-plugin

cobertura plugin with project name

Right now it just uses the project name. I suppose this could become a configurable item? I'll be glad to work on it more if something else is needed, and could probably even package the changes up in a way that upstream will take them.

The relevant code that was changed was in CoverageResult.java. Added a method:

public String getJobName() {
    AbstractProject job = owner.getProject();
    return job.getName();
}

And in the index.jelly changed the reference from it.name to it.getJobName().

<td>${it.getJobName()}</td>

It will be a bit harder to make it on a per-report basis. The report itself does not have a name or title field - and this plugin does not control the format, it just reads it.

I too am using this with a javascript project that uses karma and karma-coverage. Currently running the forked plugin in production jenkins.

EDIT: In the branch use-filename-for-reportname in my repo you will find a version of the plugin that will use the coverage file's name as the report name.

report name from file

like image 83
aet Avatar answered Sep 29 '22 13:09

aet


I suggest going to the plugin page, contacting one of the maintainers:
Stephen Connolly (id: stephenconnolly)
Manuel Carrasco Monino (id: manuel_carrasco)
Seiji Sogabe (id: ssogabe)

And asking them how you can do it.
Once you have the solution, share it here, because others (like me) might also want this capability...

I hope this helps.

like image 41
Eldad Assis Avatar answered Sep 29 '22 13:09

Eldad Assis