Use pcov to speed up tests with code coverage

main
Igor Scheller 5 years ago
parent 9329889235
commit 96cdf91c3c

@ -67,7 +67,7 @@ test:
junit: ./unittests.xml junit: ./unittests.xml
coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/' coverage: '/^\s*Lines:\s*(\d+(?:\.\d+)?%)/'
before_script: before_script:
- apk add ${PHPIZE_DEPS} && pecl install xdebug && docker-php-ext-enable xdebug - apk add -q ${PHPIZE_DEPS} && pecl install pcov > /dev/null && docker-php-ext-enable pcov
- curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer - curl -sS https://getcomposer.org/installer | php -- --no-ansi --install-dir /usr/local/bin/ --filename composer
- cp -R tests/ phpunit.xml "${DOCROOT}" - cp -R tests/ phpunit.xml "${DOCROOT}"
- HOMEDIR=$PWD - HOMEDIR=$PWD
@ -75,7 +75,7 @@ test:
- composer --no-ansi install - composer --no-ansi install
- ./bin/migrate - ./bin/migrate
script: script:
- ./vendor/bin/phpunit -v --colors=never --coverage-text --coverage-html "${HOMEDIR}/coverage/" --log-junit "${HOMEDIR}/unittests.xml" - php -d pcov.enabled=1 vendor/bin/phpunit -vvv --colors=never --coverage-text --coverage-html "${HOMEDIR}/coverage/" --log-junit "${HOMEDIR}/unittests.xml"
- ./bin/migrate down - ./bin/migrate down
check-style: check-style:

@ -101,6 +101,11 @@ vendor/bin/phpunit --testsuite Feature
vendor/bin/phpunit vendor/bin/phpunit
``` ```
To run code coverage reports its highly recommended to use [`pcov`](https://github.com/krakjoe/pcov) or at least `phpdbg -qrr`(which has problems with switch case statements) as using Xdebug slows down execution.
```bash
php -d pcov.enabled=1 vendor/bin/phpunit --testsuite Unit --coverage-text
```
### CI & Build Pipeline ### CI & Build Pipeline
The engelsystem can be tested and automatically deployed to a testing/staging/production environment. The engelsystem can be tested and automatically deployed to a testing/staging/production environment.
This functionality requires a [GitLab](https://about.gitlab.com/) server with a working docker runner. This functionality requires a [GitLab](https://about.gitlab.com/) server with a working docker runner.

@ -2,9 +2,9 @@
FROM php:7-fpm-alpine AS es_php_fpm FROM php:7-fpm-alpine AS es_php_fpm
WORKDIR /var/www WORKDIR /var/www
RUN apk add --no-cache icu-dev $PHPIZE_DEPS && \ RUN apk add --no-cache icu-dev $PHPIZE_DEPS && \
pecl install xdebug && \ pecl install pcov xdebug && \
docker-php-ext-install intl pdo_mysql && \ docker-php-ext-install intl pdo_mysql && \
docker-php-ext-enable xdebug docker-php-ext-enable pcov xdebug
RUN echo -e "xdebug.remote_enable=1\nxdebug.remote_connect_back=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini RUN echo -e "xdebug.remote_enable=1\nxdebug.remote_connect_back=1\n" >> /usr/local/etc/php/conf.d/xdebug.ini
ENV TRUSTED_PROXIES 10.0.0.0/8,::ffff:10.0.0.0/8,\ ENV TRUSTED_PROXIES 10.0.0.0/8,::ffff:10.0.0.0/8,\

@ -74,6 +74,6 @@ class SessionServiceProvider extends ServiceProvider
*/ */
protected function isCli() protected function isCli()
{ {
return PHP_SAPI == 'cli'; return PHP_SAPI == 'cli' || PHP_SAPI == 'phpdbg';
} }
} }

Loading…
Cancel
Save