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

When measuring branch or line coverage with Jacoco XML as source, the… #10788

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
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