3

Currently we have written some unit test for our php laravel 5.5 application using codeception. just for additional info, our laravel code base have around 200k LOC. For normal unit test run, we noticed that it is really fast in which we can get more than 200 tests to finish within 1 hour.

But the main issue is that when we enabled codecoverage in codeception which is using xdebug by default, we noticed the execution time increased drastically.

Now it already took 1 week but the whole codecoverage execution not even finished yet.

I am not sure whether this is the problem from codeception or xdebug itself but if anybody have experiences running php codecoverage on a huge codebase, it would be nice if you can share how you achieve it. Would appreciate it also if somebody can suggest any other tools to look into. Currently we are considering switching to phpunit but are still open to other tools to explore.

AlamHo
  • 193
  • 1
  • 3
  • 12

2 Answers2

2

Replacing Codeception with PHPUnit will be a lot of work for little gain, because Codeception uses PHPUnit and its PHP-Code-Coverage library under the hood.

There is a new code coverage extension, called pcov which is supposedly much faster than xdebug. https://github.com/krakjoe/pcov/blob/develop/INSTALL.md

I haven't tried to use it, but be aware that it requires PHPUnit 8, which is only available on PHP 7.2 or later versions.

Naktibalda
  • 13,705
  • 5
  • 35
  • 51
  • Does that mean that on php currently there are no known code coverage tool that can be run on a huge codebase? Another idea that we had was to break the monolithic apps into microservices but that would require major rewrite of the entire application. Thanks for the reply anyway – AlamHo Mar 26 '19 at 00:34
  • 1
    You can use pcov on whatever size codebase you like ... you may also use pcov on versions of PHPUnit before 8 (tested down to 6.5), with some hackery ... hackery contained in https://github.com/krakjoe/pcov-clobber ... my advice (I wrote pcov) would be to update to PHPUnit 8, as soon as possible ... – Joe Watkins Mar 26 '19 at 19:00
1

Recently I have seen code coverage sped up by replacing xdebug with phpdbg - I can't give exact numbers as the code base has extensive functional tests in its test run (and the speed-up was only for unit tests), but a 2+ hour test and coverage run has been reduced to around 50 minutes.

Note that xdebug and phpdbg can differ in their code coverage (it looked like xdebug better dealt with opcache optimisations).

edit:

Since replacing xdebug with phpdbg, I have seen further speed improvements by replacing phpdbg with pcov.

tschumann
  • 2,776
  • 3
  • 26
  • 42