Xdebug 3: Code Coverage for Websites

preview_player
Показать описание
In this video I am showing how to collect code coverage information for a website, instead of unit tests for which this is normally used.

Code used:

Рекомендации по теме
Комментарии
Автор

Coming along 3 years later in September 2024, to note that in the current version of doesn't have an includeDirectory method any more. I worked round it by just building a static list of files in my project into an include file, and then just called the Filter->includeFiles method with that list instead. Also, if you are not using any other routing (my project was not), you can use the save-code-coverage script just as it is a router, provided you just add

return false;

at the end. (return false is used in the router script for the built in web server to just cause the requested URI to be served as is, which is what was needed for my project).

Brilliant video though - it showed exactly what I wanted.

frubert
Автор

this is pure gold. thanks for all your high quality videos, podcast and xdebugger :)

easteregg
Автор

Hi, I'm new to using xdebug and analysing code coverage. Unlike here, I'm using unit testing to cover the code I'm working on. I've reached 100% line coverage so I'm analysing path coverage now. However, this is a bit of a challenge as the report seems a bit vague on potential paths that need to be covered in my test cases. I'm currently going through the code coverage analysis bit of the xdebug documentation and I see here that there is a tool that can be used to diagrammatize the coverage using the dump_branch_coverage(). There's no information on how this can be used particularly just a link redirecting to the source code. I have xdebug installed but my IDE doesn't recognise this function, some more information on this would really be helpful🙂.

mazvitaselemani
Автор

Would've been nice to link to gists of the code. However, this is the only good explanation of how to do this I've encountered.

MoonWho
Автор

Hi Dereck! Is it possible use xdebug 3 and coverage mode with nginx and php-fpm? Thanks in advance!

fernandocastanotorres
Автор

Is code coverage using all the files specified in the Filter or only those that are actually included/parsed by the running script and are in the Filter?

bartech