Skip to content

Commit

Permalink
Add integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
uhafner committed Jan 17, 2024
1 parent f4c8461 commit d00e837
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public ListBoxModel doFillParserItems() {
ListBoxModel options = new ListBoxModel();
add(options, Parser.JACOCO);
add(options, Parser.COBERTURA);
add(options, Parser.OPEN_COVER);
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

ci.jenkins.io / Code Coverage

Not covered line

Line 151 is not covered by tests

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 @@ -208,7 +208,7 @@ public enum Parser {
"symbol-footsteps-outline plugin-ionicons-api"),
JACOCO(Messages._Parser_JaCoCo(), "**/jacoco.xml",
"symbol-footsteps-outline plugin-ionicons-api"),
OPEN_COVER(Messages._Parser_JaCoCo(), "**/jacoco.xml",
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"),
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>

0 comments on commit d00e837

Please sign in to comment.