Solution - Laravel Test Case Warning And Coverage-Report File Not Generating

Today we are going to learn about a common issue that is faced by most laravel Developers. Laravel is a PHP Framework, and today's topic or article is related to one unit test case warning and coverage-report file.

When we are working with unit test cases and code-coverage, we have to check the code-coverage for the percentage of code, and which functions are covered in code-coverage or unit testing.

Basically, unit testing is a functionality where you can check your code with your expected output with static or dynamic input. It shows how your function is going to work and what will be its output.

So, to check code-coverage, we require two XML file, from which one is the coverage-report.xml file. To generate this file we execute the following code:

./vendor/bin/phpunit --coverage-clover coverage-report.xml

But, sometimes this code works perfectly, but in result it gives you a warning as seen below:

Warning :         XDEBUG_MODE=coverage or xdebug.mode=coverage has to be set

So, this is the warning that if we are working with the coverage and we want to generate a coverage-report file we need to set a XDEBUG_MODE . The question is, where do we have to set this?

We don't have to make any changes to any configuration files. We just have to set the XDEBUG_MODE into the command itself as following:

XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-clover coverage-report.xml

I hope this article is helpful to you and you can share questions if you have any.


Similar Articles