View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0001938 | Xdebug | Code Coverage | public | 2021-01-23 16:01 | 2021-02-24 17:57 |
Reporter | jonnybarnes | Assigned To | derick | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | acknowledged | Resolution | open | ||
Platform | Apple | OS | macOS | OS Version | 11.1 |
Product Version | 3.0.2 | ||||
Summary | 0001938: Branches in traist aren’t marked as executed | ||||
Description | I initially thought this was an error in PHPUnit and reported there. They said it was a bug in XDebug itself. This is definitely happening in PHP8 with XDebug 3, it may be happening on older versions as well? If I have a method in a trait, and use that method in a class, and look for code coverage based on branches, I can not get 100% coverage. Here’s a smallest reproducible example: https://github.com/jonnybarnes/trait-path-coverage The paths and branches for the trait are marked as zero coverage: ``` App\FooTrait Methods: 100.00% ( 1/ 1) Paths: 0.00% ( 0/ 1) Branches: 0.00% ( 0/ 1) Lines: 100.00% ( 1/ 1) ``` | ||||
Steps To Reproduce | Import a trait into a class and use its methods. Then measure the path or branch coverage of the codebase. the trait will have 0% path and branch coverage. | ||||
Additional Information | One of the contributors over at PHPUnit thinks it’s a bug in XDebug, they provided this additional information on my bug report from their testing on my minimal case repo: ``` C:\tmp\trait-path-coverage\src\Bar.php = {array} [2] lines = {array} [4] 7 = {int} 1 13 = {int} 1 14 = {int} -2 16 = {int} 1 functions = {array} [2] App\Bar->useTrait = {array} [2] branches = {array} [1] 0 = {array} [7] op_start = {int} 0 op_end = {int} 8 line_start = {int} 11 line_end = {int} 14 hit = {int} 1 out = {array} [0] out_hit = {array} [0] paths = {array} [1] {main} = {array} [2] branches = {array} [1] 0 = {array} [7] op_start = {int} 0 op_end = {int} 3 line_start = {int} 3 line_end = {int} 16 hit = {int} 1 out = {array} [1] out_hit = {array} [1] paths = {array} [1] C:\tmp\trait-path-coverage\src\FooTrait.php = {array} [2] lines = {array} [3] 11 = {int} 1 <------------------------------------------- this says the line was executed 12 = {int} -2 14 = {int} 1 functions = {array} [2] App\FooTrait->returnsTrue = {array} [2] branches = {array} [1] 0 = {array} [7] op_start = {int} 0 op_end = {int} 5 line_start = {int} 9 line_end = {int} 12 hit = {int} 0 <----------------------------------------- this says the branch was not out = {array} [0] out_hit = {array} [0] paths = {array} [1] {main} = {array} [2] branches = {array} [1] 0 = {array} [7] op_start = {int} 0 op_end = {int} 2 line_start = {int} 3 line_end = {int} 14 hit = {int} 1 out = {array} [1] out_hit = {array} [1] paths = {array} [1] ``` | ||||
Tags | No tags attached. | ||||
Operating System | |||||
PHP Version | 8.0.0-8.0.4 | ||||
Date Modified | Username | Field | Change |
---|---|---|---|
2021-01-23 16:01 | jonnybarnes | New Issue | |
2021-02-18 11:21 | derick | Assigned To | => derick |
2021-02-18 11:21 | derick | Status | new => acknowledged |
2021-02-18 11:21 | derick | Note Added: 0005669 |