CakePHP4 Cannot Generate Code Coverage

Asked 2 years ago, Updated 2 years ago, 73 views

Create a controller test with CakePHP4 and
I tried to generate code coverage, but I couldn't.

Refer to the article below and

Cookbook > Test > Generate Code Coverage
https://book.cakephp.org/4/ja/development/testing.html#id9

As described in this article, I executed the following command:

phpunit --coverage-html webroot/coverage tests/TestCase/Controller/〇 Con ControllerTest.php

The following error occurs and no code coverage is generated:

Cannot open file "tests/TestCase/Controller/〇 Con ControllerTest.php".

If you ls the controller you are testing, it will appear as follows:
ls

If you know the cause and how to deal with it, I would appreciate it if you could let me know.

I look forward to your kind cooperation.

<Each version>
PHP 8.0.12
CakePHP 4.2.10
PHPUnit 3.7.21

*We are also asking the same question on teratail: .

cakephp phpunit

2022-09-30 19:38

1 Answers

The following command using phpdbg instead of xdebug was able to generate code coverage:

phpdbg-qrr vendor/phpunit/phpunit/phpunit --coverage-html webroot/coverage tests/TestCase/Controller/○○Test.php


2022-09-30 19:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.