Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Codeception codecoverage painfully slow

I am using codeception (with codecoverage) to check the code coverage of an application I have written using the Yii2 framework. Because the standard php installation on my mac has xcode not enabled, I activated it adding a zend_module line to my php.ini. Code coverage seems to work now but is painfully slow. Yes I know that the activated xdebug and coverage generation takes some time, but I think this is not normal: Even a simple unit test which checks only the initialization of an object takes up to 15 minutes.

I don't think that it is a cpu or ram problem rather than a configuration problem.

I start code coverage with:

codeception run unit --coverage-html

Things I detected: The first test runs always fast regardless how big it is. The second test is much slower (regardless what test it is) and the third is more slowly. How can I track this down? I want to detect the problem.

Again: I know that codecoverage slows down tests, but 15 minutes for a simple test is not normal.

//EDIT: The test that runs approx. 15 minutes, takes 1 second without code-coverage enabled.

like image 503
palima Avatar asked Aug 31 '14 09:08

palima


People also ask

Can codeception collect code coverage data for remote tests?

Coverage data can be collected manually for both local and remote tests. Remote tests may be executed on different nodes, or locally but running through web server. It may look hard to collect code coverage for Selenium tests or PhpBrowser tests. But Codeception supports remote codecoverage as well as local.

How do I include all subdomains in codeception code coverage?

By default, Codeception will run code coverage only for the domain set in the url of the WebDriver/url (or c3_url if defined), thus leaving out other subdomains from code coverage. To avoid that and to include all relevant subdomains in code covereage, it’s advised to set .mysite.com as the cookie domain option:

How to gather codecoverage from a local application?

After the c3.php file is included in application you can start gather coverage. In case you execute your application locally there is nothing to be changed in config. All codecoverage reports will be collected as usual and merged afterwards. Think of it: Codeception runs remote coverage in the same way as local.

How to collect codecoverage for unit tests?

The basic codecoverage can be collected for functional and unit tests. If you performed configuration steps from above, you are ready to go. All you need is to execute codeception with --coverage option. To generate a clover xml report or a tasty html report append also --coverage-xml and --coverage-html options.


1 Answers

You need xdebug enabled to get the coverage (which you have now done!) so disabling it will not help.

There is a huge overhead when running these sort of analysis checks, for example my Laravel app runes ~300 tests and ~1000 assertions. When getting coverage reports it takes about 5 mins to run, but with xdebug switched off and no coverage its about 15 seconds.

You maybe able to get some more performance configuring your php.ini? Maybe check how much memory you are allowing php to consume. I think default its 128mb, allowing some more may stop memory/disk grind?

If it is your application that is complicated, maybe enable profiling in xdebug, and analyse the results in PHPStorm and see what is slowing things down.

like image 158
OnIIcE Avatar answered Oct 18 '22 00:10

OnIIcE