From 5e0022940b4561e321c08bcfb6466dd3483377d6 Mon Sep 17 00:00:00 2001 From: Frank Niessink Date: Thu, 6 Feb 2025 10:52:44 +0100 Subject: [PATCH] When measuring branch or line coverage with Jacoco XML as source, the coverage would be calculated incorrectly. Fixes #10787. --- .../tests/source_collectors/jacoco/base.py | 25 ++++++++++++++++--- .../jacoco/test_uncovered_branches.py | 1 - .../jacoco/test_uncovered_lines.py | 1 - docs/src/changelog.md | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/components/collector/tests/source_collectors/jacoco/base.py b/components/collector/tests/source_collectors/jacoco/base.py index bf65758a48..e88a679087 100644 --- a/components/collector/tests/source_collectors/jacoco/base.py +++ b/components/collector/tests/source_collectors/jacoco/base.py @@ -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 = """ + + + + + + + + + + + + + + + + + + +""" 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") diff --git a/components/collector/tests/source_collectors/jacoco/test_uncovered_branches.py b/components/collector/tests/source_collectors/jacoco/test_uncovered_branches.py index 1d5a2e63ba..c4b2838dd0 100644 --- a/components/collector/tests/source_collectors/jacoco/test_uncovered_branches.py +++ b/components/collector/tests/source_collectors/jacoco/test_uncovered_branches.py @@ -7,7 +7,6 @@ class JaCoCoUncoveredBranchesTest(JaCoCoCommonCoverageTestsMixin, JaCoCoCommonTe """Unit tests for the JaCoCo metrics.""" METRIC_TYPE = "uncovered_branches" - JACOCO_XML = "" async def test_uncovered_branches_without_branches(self): """Test that a JaCoCo XML without branches results in 100% coverage.""" diff --git a/components/collector/tests/source_collectors/jacoco/test_uncovered_lines.py b/components/collector/tests/source_collectors/jacoco/test_uncovered_lines.py index fb9ad87ed9..fad17e6104 100644 --- a/components/collector/tests/source_collectors/jacoco/test_uncovered_lines.py +++ b/components/collector/tests/source_collectors/jacoco/test_uncovered_lines.py @@ -7,4 +7,3 @@ class JaCoCoUncoveredLinesTest(JaCoCoCommonCoverageTestsMixin, JaCoCoCommonTests """Unit tests for the JaCoCo metrics.""" METRIC_TYPE = "uncovered_lines" - JACOCO_XML = "" diff --git a/docs/src/changelog.md b/docs/src/changelog.md index 0fdf413170..94529f749a 100644 --- a/docs/src/changelog.md +++ b/docs/src/changelog.md @@ -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