Laravel 5: PHPUnit and no code coverage driver available

前端 未结 8 607
深忆病人
深忆病人 2020-12-25 09:49

I would like to use PHPUnit to create code coverage reports. I have tried a lot of installation setups found on the web. But nothing seems to work out.

I use the lat

相关标签:
8条回答
  • 2020-12-25 10:14

    For windows users:

    1) Download xdebug

    2) Rename the file to _php_xdebug.dll_ and copy the file to the ext folder in your php installation e.g C:\Program Files (x86)\php\ext

    3) Open your php.ini file. For me it’s available at C:\Program Files (x86)\php\php.ini.

    4) Paste the below code at the bottom of the file.

    zend_extension = php_xdebug.dll
    xdebug.remote_enable = 1
    xdebug.remote_handler = dbgp
    xdebug.remote_host = localhost
    xdebug.remote_autostart = 1
    xdebug.remote_port = 9000
    xdebug.show_local_vars = 1
    
    0 讨论(0)
  • 2020-12-25 10:15

    To Reproduce, kindly follow the solution(s) below;

    1. Steps to reproduce the behavior if you don't have Xdebug activated already:

      • Inside your project root directory open your CMD terminal and type php -i
      • A list of important information concerning your php will be listed in the CMD terminal
      • Copy and paste the output here https://xdebug.org/wizard
      • After you paste the output, click on the button Analyse my phpinfo() output to proceed
      • Follow the instructions to the latter after your redirect to the Summary page
      • After you are done with the installation, type php -v to confirm that Xdebug is activated successfully.
    2. If you already have Xdebug activated, follow these steps get test coverage running;

      • Type ./vendor/bin/phpunit --coverage-html tests/coverage into the CMD terminal to generate the test coverage
      • After it is done with running the tests successfully, the coverage report of the tests will be in the project_dir/tests/coverage directory
      • Inside the project_dir/tests/coverage directory, click on the index.html file to open and view the general report of the project's phpunit test coverage

    NB: I worked in Laravel ^6.0
    Tested in Windows 10 environment but can be replicated in other environments

    0 讨论(0)
提交回复
热议问题