Skip to content

Commit

Permalink
Merge pull request #12 from jenkinsci/wrong-cobertura-counters
Browse files Browse the repository at this point in the history
Parse all digits of a counter before and after the slash
  • Loading branch information
uhafner authored Apr 13, 2023
2 parents 6150a05 + ec858a8 commit 1241682
Show file tree
Hide file tree
Showing 4 changed files with 412 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

<properties>
<scmTag>HEAD</scmTag>
<revision>0.23.0</revision>
<revision>0.22.2</revision>
<changelist>-SNAPSHOT</changelist>

<module.name>edu.hm.hafner.coverage</module.name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class CoberturaParser extends CoverageParser {
private static final QName METHOD = new QName("method");
private static final QName LINE = new QName("line");

private static final Pattern BRANCH_PATTERN = Pattern.compile(".*(?<covered>\\d+)/(?<total>\\d+)\\)");
private static final Pattern BRANCH_PATTERN = Pattern.compile(".*\\((?<covered>\\d+)/(?<total>\\d+)\\)");

/** Required attributes of the XML elements. */
private static final QName NAME = new QName("name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ CoberturaParser createParser() {
return new CoberturaParser();
}

@Test
void shouldCountCorrectly625() {
Node tree = readReport("cobertura-counter-aggregation.xml");

var expectedValue = new CoverageBuilder().setCovered(31).setMissed(1).setMetric(BRANCH).build();
assertThat(tree.getValue(BRANCH)).isPresent().contains(expectedValue);
}

@Test
void shouldReadCoberturaIssue610() {
Node tree = readReport("coverage-missing-sources.xml");
Expand Down
Loading

0 comments on commit 1241682

Please sign in to comment.