Skip to content

Fix coverage parsing for projects that use namespaces#337

Open
DaDummy wants to merge 3 commits intorecca0120:mainfrom
DaDummy:bugfix/coverage-parser
Open

Fix coverage parsing for projects that use namespaces#337
DaDummy wants to merge 3 commits intorecca0120:mainfrom
DaDummy:bugfix/coverage-parser

Conversation

@DaDummy
Copy link

@DaDummy DaDummy commented Dec 12, 2025

In projects with more than one namespace the coverage was not correctly parsed.

Having multiple namespaces resulted in the following hierarchy being output by the XMLParser:

{
    "node": {
        "?xml": {
            "@_version": "1.0",
            "@_encoding": "UTF-8"
        },
        "coverage": {
            "project": {
                "package": [
                    {
                        "file": {
                            /* ... */
                        }
                    },
                    {
                        "file": [
                            {
                                /* ... */
                            }
                        ]
                    }
                ]
            }
        }
    }
}

This was not correctly handled by querySelectorAll, which assumed that only the innermost selected node could be an array.

This MR corrects that.

@codecov
Copy link

codecov bot commented Dec 15, 2025

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.42%. Comparing base (cdc47bf) to head (4e8d671).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
src/PHPUnit/Element.ts 80.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #337      +/-   ##
==========================================
- Coverage   95.52%   95.42%   -0.11%     
==========================================
  Files          60       60              
  Lines        4516     4520       +4     
  Branches     1012     1012              
==========================================
- Hits         4314     4313       -1     
- Misses        197      203       +6     
+ Partials        5        4       -1     
Flag Coverage Δ
unittests 95.33% <80.00%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DaDummy DaDummy force-pushed the bugfix/coverage-parser branch from 4e8d671 to 9a327a4 Compare January 21, 2026 14:47
@DaDummy
Copy link
Author

DaDummy commented Jan 21, 2026

The observed issue and new code should now be covered in the tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants