Ole*_*kin 2 phpunit code-coverage xdebug
我有一个带有大量测试的 Laravel 项目。我使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但 pcov 不支持分支覆盖,所以我决定使用 xdebug。
使用 xdebug 测试执行,使用代码覆盖率但不使用 --path-coverage(分支覆盖率)大约需要 8 分钟。
但是使用 xdebug、代码覆盖率和 --path-coverage(分支覆盖率)测试执行需要超过 2 个小时,甚至不能等到结束:
INFO[2021-09-14 21:33:24] Executing runtests with coverage xdebug
XDEBUG_MODE=coverage
php artisan test --parallel --processes=8 --verbose --passthru=--path-coverage tests/Feature --coverage-text
Warming cache for static analysis ... done [00:00.071]
............S................................................ 61 / 1180 ( 5%)
............................................................. 122 / 1180 ( 10%)
............................................................. 183 / 1180 ( 15%)
............................................................. 244 / 1180 ( 20%)
.......
INFO[2021-09-15 00:00:05] finished in 2h 26m 40.458565176s
Run Code Online (Sandbox Code Playgroud)
所以我的问题是 --path-coverage 执行超过 100 倍是正常的吗?
总而言之:是的,这是预期的。
\nXdebug 需要做很多事情才能确定这些信息。
\nAll these checks, and the extra storage of data, drastically reduces performance. But that's not because Xdebug is slow, but rather because it does a lot of work.
\nIt would be nice if it was possible to only enable path/branch coverage for specific high-impact functions and methods, but I don't think that PHPUnit has a way for that (yet).
\n| 归档时间: |
|
| 查看次数: |
1216 次 |
| 最近记录: |