Questions tagged [php-code-coverage]
27 questions
3
votes
1 answer
How to get a simple phpunit codecoverage summary in text output?
I use PHPUnit 9.5.7 on php 8.0.3
I would like to have a checker for minimum code coverage of lines as a git hook.
I have seen in online examples a simple 3 line output as a summary after running the tests. How do I get this output? I searched…

Calamity Jane
- 2,189
- 5
- 36
- 68
3
votes
2 answers
Generating code coverage report in Clover XML format ... syntax error
I'm using phpstorm and wrote some test in my laravel app. The phpunit.xml is alsmost default.

lordisp
- 634
- 9
- 21
3
votes
1 answer
PHPUnit code coverage reports false positive inside foreach
PHPUnit code coverage is reporting 100% coverage for the following function which is clearly wrong:
public function run(){
foreach ([1] as $value) {
if($value === 1 ){
echo "Is called\n"; //…

David
- 2,101
- 2
- 32
- 41
3
votes
0 answers
Phpunit Code Coverage is not catching my code
I am trying to do phpunit testing using codeception and guzzle on my API written on php, all the tests are running but the codecoverage is always showing 0/0.
I am sharing my test function below
public function testInputget()
{
$c = $this->id;
//…

Utsav Chatterjee
- 41
- 1
- 3
2
votes
2 answers
How to know if xdebug is right?
I'm running some tests and some reports don't make sense for example:
I also have another example:
Why xdebug marks 587 and 588 as not executed and 589 as executed?

Andrei Lupuleasa
- 2,677
- 3
- 14
- 32
2
votes
2 answers
PHP Unit not working on Ubuntu 12.04 LTS with PHP5.6
Any one can help me to solve my problem. I want to run phpunit on php5.6 but got the issue
:~$ phpunit
PHP Warning: require_once(PHP/CodeCoverage/Filter.php): failed to open stream: No such file or directory in /usr/bin/phpunit on line 38
PHP Fatal…

Vipin Kumar
- 71
- 1
- 4
2
votes
1 answer
How to get the PHP Code Coverage working with phpdbg on a Windows Server?
Since I still have troubles with PHPUnit / PHP Code Coverage and Xdebug, I decided to try it another way -- with phpdbg.
I did it as hier shown. Tried in CMD and also in Git Bash, but the result is the same, it fails:
$ composer info | grep…

automatix
- 14,018
- 26
- 105
- 230
1
vote
1 answer
php - PHPUnit with PCOV code coverage show 0% coverage on window
I use phpUnit with PCOV on code coverage on window. But somehow, I get 0.0% code coverage. I am sure the function is called. Why is this happening?
Versions:
PHP: 8.1.12
PHPUnit: 9.5.0
PCOV: 1.0.11
The running log is as follows
PS C:\xampp\php>…

george
- 11
- 1
1
vote
0 answers
PHP code coverage - Understanding path coverage
I just started working on a piece of software using PHP 7.4.27 with PHPUnit 9.5.7 and Xdebug 2.9.8. I am collection code coverage including branch and path coverage information for all my unit tests. In class "Content" I have a method named "unwrap"…

CrasyHorse
- 51
- 1
1
vote
0 answers
PHPUnit with Clover code coverage reports: tests are not executed and commands exit
I "inherited" a very old PHP project compatible only with PHP 5.6 and written without any framework, and I'm trying to "modernize" it for PHP 7.x and adding some unit tests and some code inspection tools like SonarQube with Jenkins.
The project has…

Mat
- 586
- 2
- 10
- 25
1
vote
0 answers
How can I determine the code coverage of my unit tests?
I am trying to determine the code-coverage of a group of unit tests. How can I do this?
I have phpUnit and XDebug installed on my machine and from what I understand these tools will do the job but I don't know how.
I've tried running
phpunit…

J Olson
- 167
- 2
- 8
1
vote
3 answers
PHP multiple function return types String|int
I've come across a bit unusual scenario where my function returns multiple types string or integer. I'm trying to declare return types. Could anyone please suggest me the best practice here to declare.
I'm aware that null or other type I can use…

Developer
- 3,857
- 4
- 37
- 47
1
vote
1 answer
PHPUnit Mocked classes methods not shown as covered in code coverage reports?
I am working on a php project in magento2. I am using mock objects for writing unit test cases. I came to know that when i generate code coverage report, Mocked classes and methods do not show as covered in code coverage reports, Is there any way we…

Kapil Yadav
- 650
- 1
- 5
- 29
1
vote
1 answer
How to use the PHP_CodeCoverage library directly?
I'm trying to get the PHP_CodeCoverage library working for the simplest possible case to create an HTML code coverage report, and failing. I have PHP and Xdebug installed. I would rather not specify the versions of those that I am using because I'm…

still_dreaming_1
- 8,661
- 6
- 39
- 56
1
vote
1 answer
How to setup Laravel Boilerplate phpunit to provide code coverage in Homestead environment
I have a fresh Laravel Boilerplate running on a Laravel Homestead environment which runs perfect.
The php -v command was returning me this info
PHP 7.1.2-3+deb.sury.org~xenial+1 (cli) (built: Feb 22 2017 10:08:33) ( NTS )
Copyright (c) 1997-2017 The…

Matheus Vellone
- 79
- 1
- 2
- 8