LoginSignup
0
0

More than 1 year has passed since last update.

Code coverage driver not available.

Posted at

coverageするとエラーがでるのでメモ

php artisan test --coverage

   ERROR  Code coverage driver not available.

image.png

教えてSenpai

Xdebugをインストールでなおりました。 https://xdebug.org/wizardphpinfo();php -iを貼り付けてインストールしましょう

sudo apt install -y php-dev autoconf automake \
  && wget https://xdebug.org/files/xdebug-3.2.0.tgz \
  && tar xf xdebug-3.2.0.tgz \
  && cd xdebug-3.2.0 \
  && phpize \
  && ./configure \
  && make \
  && cp modules/xdebug.so /opt/php/8.2.0/lib/php/extensions/no-debug-non-zts-20220829 \
  && echo zend_extension=xdebug > /opt/php/8.2.0/ini/conf.d/99-xdebug.ini \
  && echo xdebug.mode=coverage > /opt/php/8.2.0/ini/conf.d/99-xdebug.ini

xdebug.modeにcoverageを含めないと下記のエラーになります。

APP_KEY=$(php artisan key:generate --show) php artisan test --coverage

   ERROR  Code coverage driver not available. Did you set Xdebug's coverage mode?

image.png

xdebug.modeの一覧

無事カバレッジがとれました🎉
image.png

HTMLにも出力できます!

php artisan test --coverage-html coverage

image.png

php -S 0.0.0.0:8000 -t coverage

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0