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

Add support for OpenCover #60

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The Jenkins Coverage Plug-in collects reports of code coverage or mutation cover

- [JaCoCo](https://www.jacoco.org/jacoco): Code Coverage
- [Cobertura](https://cobertura.github.io/cobertura/): Code Coverage
- [OpenCover](https://github.com/OpenCover/opencover): Code Coverage
- [PIT](https://pitest.org/): Mutation Coverage
- [JUnit](https://ant.apache.org/manual/Tasks/junitreport.html): Test Results

Expand Down
2 changes: 1 addition & 1 deletion plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<gitHubRepo>jenkinsci/coverage-plugin</gitHubRepo>

<!-- Library Dependencies Versions -->
<coverage-model.version>0.37.0</coverage-model.version>
<coverage-model.version>0.38.0</coverage-model.version>
<jsoup.version>1.17.2</jsoup.version>

<!-- Jenkins Plug-in Dependencies Versions -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public Optional<Delta> calculateCodeDeltaToReference(final Run<?, ?> referenceBu
}

/**
* Gets all code changes which are relevant for the coverage (added, renamed and modified files).
* Gets all code changes that are relevant for the coverage (added, renamed and modified files).
*
* @param delta
* The calculated code {@link Delta}
Expand All @@ -103,7 +103,7 @@ public Set<FileChanges> getCoverageRelevantChanges(final Delta delta) {
}

/**
* Maps the passed {@link FileChanges code changes} to the corresponding fully qualified names as they are used by
* Maps the given {@link FileChanges code changes} to the corresponding fully qualified names as they are used by
* the coverage reporting tools - usually the fully qualified name of the file.
*
* @param changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
ListBoxModel options = new ListBoxModel();
add(options, Parser.JACOCO);
add(options, Parser.COBERTURA);
add(options, Parser.OPENCOVER);

Check warning on line 151 in plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java

View check run for this annotation

Codecov / codecov/patch

plugin/src/main/java/io/jenkins/plugins/coverage/metrics/steps/CoverageTool.java#L151

Added line #L151 was not covered by tests
add(options, Parser.PIT);
add(options, Parser.JUNIT);
return options;
Expand Down Expand Up @@ -207,6 +208,8 @@
"symbol-footsteps-outline plugin-ionicons-api"),
JACOCO(Messages._Parser_JaCoCo(), "**/jacoco.xml",
"symbol-footsteps-outline plugin-ionicons-api"),
OPENCOVER(Messages._Parser_OpenCover(), "**/*opencover.xml",
"symbol-footsteps-outline plugin-ionicons-api"),
PIT(Messages._Parser_PIT(), "**/mutations.xml",
"symbol-solid/virus-slash plugin-font-awesome-api"),
JUNIT(Messages._Parser_Junit(), "**/TEST-*.xml",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Recorder.Name=Record code coverage results

Parser.Cobertura=Cobertura Coverage Reports
Parser.JaCoCo=JaCoCo Coverage Reports
Parser.OpenCover=OpenCover Coverage Reports
Parser.PIT=PIT Mutation Testing Reports
Parser.Junit=JUnit Test Results

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,25 @@ private void verifyForOneCoberturaAndOneJacoco(final ParameterizedJob<?, ?> proj
"- Source file 'edu/hm/hafner/analysis/registry/ProtoLintDescriptor.java' not found",
"- Source file 'edu/hm/hafner/analysis/registry/GoLintDescriptor.java' not found",
"- Source file 'edu/hm/hafner/analysis/ModuleResolver.java' not found",
" ... skipped logging of 289 additional errors ...",
" ... skipped logging of 289 additional errors ...",
" ... skipped logging of 289 additional errors ...");
}

@Test
void shouldRecordOneOpenCoverResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.OPENCOVER, "opencover.xml");

Run<?, ?> build = buildSuccessfully(project);

CoverageBuildAction coverageResult = build.getAction(CoverageBuildAction.class);
assertThat(coverageResult.getAllValues(Baseline.PROJECT))
.filteredOn(Value::getMetric, Metric.LINE)
.first()
.isInstanceOfSatisfying(Coverage.class, m -> {
assertThat(m.getCovered()).isEqualTo(9);
assertThat(m.getTotal()).isEqualTo(15);
});
}

@Test
void shouldRecordOnePitResultInFreestyleJob() {
FreeStyleProject project = createFreestyleJob(Parser.PIT, "mutations.xml");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="utf-8"?>
<CoverageSession>
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="1" numClasses="1" visitedMethods="1" numMethods="1" />
<Modules>
<Module hash="31750BAB-054A-4C4B-8763-D76F95F0353A">
<ModulePath>ClassLibrary.dll</ModulePath>
<ModuleTime>2019-12-13T01:36:13</ModuleTime>
<ModuleName>ClassLibrary</ModuleName>
<Files>
<File uid="1" fullPath="[PLACEHOLDER]" />
</Files>
<Classes>
<Class>
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="1" numClasses="1" visitedMethods="1" numMethods="1" />
<FullName>ClassLibrary.LibraryClass</FullName>
<Methods>
<Method cyclomaticComplexity="6" nPathComplexity="0" sequenceCoverage="60" branchCoverage="50" isConstructor="False" isGetter="False" isSetter="False" isStatic="True">
<Summary numSequencePoints="15" visitedSequencePoints="9" numBranchPoints="6" visitedBranchPoints="3" sequenceCoverage="60" branchCoverage="50" maxCyclomaticComplexity="6" minCyclomaticComplexity="6" visitedClasses="0" numClasses="0" visitedMethods="1" numMethods="1" />
<MetadataToken />
<Name>System.Int32 ClassLibrary.LibraryClass::Sum(System.Int32,System.Int32)</Name>
<FileRef uid="1" />
<SequencePoints>
<SequencePoint vc="2" uspid="8" ordinal="0" sl="8" sc="1" el="8" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="9" ordinal="1" sl="9" sc="1" el="9" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="10" ordinal="2" sl="10" sc="1" el="10" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="13" ordinal="3" sl="13" sc="1" el="13" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="14" ordinal="4" sl="14" sc="1" el="14" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="16" ordinal="5" sl="16" sc="1" el="16" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="17" ordinal="6" sl="17" sc="1" el="17" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="19" ordinal="7" sl="19" sc="1" el="19" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="0" uspid="20" ordinal="8" sl="20" sc="1" el="20" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="22" ordinal="9" sl="22" sc="1" el="22" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="23" ordinal="10" sl="23" sc="1" el="23" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="25" ordinal="11" sl="25" sc="1" el="25" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="1" uspid="26" ordinal="12" sl="26" sc="1" el="26" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="28" ordinal="13" sl="28" sc="1" el="28" ec="2" bec="0" bev="0" fileid="1" />
<SequencePoint vc="2" uspid="29" ordinal="14" sl="29" sc="1" el="29" ec="2" bec="0" bev="0" fileid="1" />
</SequencePoints>
<BranchPoints>
<BranchPoint vc="0" uspid="10" ordinal="1" path="1" offset="8" offsetend="35" sl="10" fileid="1" />
<BranchPoint vc="0" uspid="10" ordinal="2" path="2" offset="8" offsetend="44" sl="10" fileid="1" />
<BranchPoint vc="0" uspid="10" ordinal="3" path="3" offset="8" offsetend="53" sl="10" fileid="1" />
<BranchPoint vc="1" uspid="10" ordinal="4" path="4" offset="8" offsetend="62" sl="10" fileid="1" />
<BranchPoint vc="1" uspid="10" ordinal="5" path="5" offset="8" offsetend="71" sl="10" fileid="1" />
<BranchPoint vc="2" uspid="10" ordinal="0" path="0" offset="8" offsetend="80" sl="10" fileid="1" />
</BranchPoints>
<MethodPoint vc="9" uspid="0" p8:type="SequencePoint" ordinal="0" offset="0" sc="0" sl="8" ec="1" el="29" bec="0" bev="0" fileid="1" xmlns:p8="xsi" />
</Method>
</Methods>
</Class>
</Classes>
</Module>
</Modules>
</CoverageSession>
Loading