-
Notifications
You must be signed in to change notification settings - Fork 475
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
HTTP tests are not included in test coverage by pcov #657
Comments
Does this work as expected if you run the command outside of sail? |
Yes, it does work as expected in CI pipeline with xdebug. |
Heya, thanks for reporting. We'll need more info and/or code to debug this further. Can you please create a repository with the command below, commit the code that reproduces the issue as one separate commit on the main/master branch and share the repository here? Please make sure that you have the latest version of the Laravel installer in order to run this command. Please also make sure you have both Git & the GitHub CLI tool properly set up. laravel new bug-report --github="--public" Please do not amend and create a separate commit with your custom changes. After you've posted the repository, we'll try to reproduce the issue. Thanks! |
Hi @driesvints. Thank you for looking into this. I think I found explanation of why Http tests are ignored. In our app we have not only "app" directory (which contains controllers) but also "src" directory (which contains domain layer of the app). When I move controllers from the "app" dir to "src", they are included in code coverage correctly. Apparently PCOV ignores the "app" directory even though I have specified both paths in phpunit.xml configuration.
|
Hi @salvisb. Glad you found that. Does the coverage report work when you run the test command out of sail? |
@driesvints as I wrote before, coverage report work as expected with xdebug (outside of Sail). I think the issue is purely with pcov configuration. Update: Tried running pcov outside of Sail and it behaves the same way, i.e. tests in "app" are not included in coverage. By the way @driesvints, is it possible to switch from pcov to xdebug for measuring code coverage in Sail? |
From what I can tell the collision library first checks for pcov, then xdebug. I'm not sure if it can be forced to use xdebug. Since this is probably more a collision issue than sail, I suggest to open an issue on their tracker. https://github.com/nunomaduro/collision/blob/v8.x/src/Coverage.php#L45 |
Sail Version
1.21.2
Laravel Version
10.40.0
PHP Version
8.2.5
Operating System
macOS
OS Version
14.1.1
Description
Hi, we have several HTTP tests for checking controller logic. However, when running
sail artisan test --coverage
all of the controller classes has 0% coverage. Unit tests are showing up just fine. Could it be that unlike xdebug, pcov is not capable of measuring coverage of the HTTP tests? Or it's somehow configurable? Thanks!Steps To Reproduce
sail artisan test --coverage
The text was updated successfully, but these errors were encountered: