Skip to content

Commit

Permalink
When measuring branch or line coverage with Jacoco XML as source, the…
Browse files Browse the repository at this point in the history
… coverage would be calculated incorrectly.

Fixes #10787.
  • Loading branch information
fniessink committed Feb 6, 2025
1 parent 772beab commit 5e00229
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
25 changes: 22 additions & 3 deletions components/collector/tests/source_collectors/jacoco/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,34 @@ async def test_zipped_report_without_xml(self):
class JaCoCoCommonCoverageTestsMixin:
"""Tests common to JaCoCo coverage collectors."""

JACOCO_XML = "Subclass responsibility"
JACOCO_XML = """
<report>
<package>
<class>
<method>
<counter type='LINE' missed='2' covered='4'/>
<counter type='BRANCH' missed='2' covered='4'/>
</method>
</class>
<class>
<method>
<counter type='LINE' missed='0' covered='3'/>
<counter type='BRANCH' missed='0' covered='3'/>
</method>
</class>
</package>
<counter type='LINE' missed='2' covered='7'/>
<counter type='BRANCH' missed='2' covered='7'/>
</report>
"""

async def test_coverage(self):
"""Test that the number of uncovered lines/branches and the total number of lines/branches are returned."""
response = await self.collect(get_request_text=self.JACOCO_XML)
self.assert_measurement(response, value="2", total="6")
self.assert_measurement(response, value="2", total="9")

async def test_zipped_report(self):
"""Test that a zipped report can be read."""
self.set_source_parameter("url", "https://example.org/jacoco.zip")
response = await self.collect(get_request_content=self.zipped_report(("jacoco.xml", self.JACOCO_XML)))
self.assert_measurement(response, value="2", total="6")
self.assert_measurement(response, value="2", total="9")
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ class JaCoCoUncoveredBranchesTest(JaCoCoCommonCoverageTestsMixin, JaCoCoCommonTe
"""Unit tests for the JaCoCo metrics."""

METRIC_TYPE = "uncovered_branches"
JACOCO_XML = "<report><counter type='BRANCH' missed='2' covered='4'/></report>"

async def test_uncovered_branches_without_branches(self):
"""Test that a JaCoCo XML without branches results in 100% coverage."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ class JaCoCoUncoveredLinesTest(JaCoCoCommonCoverageTestsMixin, JaCoCoCommonTests
"""Unit tests for the JaCoCo metrics."""

METRIC_TYPE = "uncovered_lines"
JACOCO_XML = "<report><counter type='LINE' missed='2' covered='4'/></report>"
1 change: 1 addition & 0 deletions docs/src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ If your currently installed *Quality-time* version is not the latest version, pl
- The comment field of a metric's technical debt tab would be editable even though the user was not logged in or when the user was time traveling. Note that the server would not save any changes made as it also checks for correct permissions. Fixes [#10739](https://github.com/ICTU/quality-time/issues/10739).
- When changing technical debt with the option "Yes, and also set technical debt target and end date" or "No, and also clear technical debt target and end date", the technical end date value would not be refreshed in the UI. Fixes [#10761](https://github.com/ICTU/quality-time/issues/10761).
- The status end date of measurement entities would not be refreshed in the UI when changing the status. Fixes [#10762](https://github.com/ICTU/quality-time/issues/10762).
- When measuring branch or line coverage with Jacoco XML as source, the coverage would be calculated incorrectly. Fixes [#10787](https://github.com/ICTU/quality-time/issues/10787).

### Changed

Expand Down

0 comments on commit 5e00229

Please sign in to comment.