Yii2: Uncaught TypeError: Argument 1 passed to PHPUnit_Framework_TestResult::setCodeCoverage() must be an instance of SebastianBergmann\CodeCoverage\CodeCoverage

Created on 29 Nov 2016  路  3Comments  路  Source: yiisoft/yii2

What steps will reproduce the problem?

I do

codecept run --coverage-html

in order to get a coverage report for my application.

What is the expected result?

A coverage report for my application

What do you get instead?

$ codecept run -vvv --coverage-html
Codeception PHP Testing Framework v2.2.6
Powered by PHPUnit 5.6.7 by Sebastian Bergmann and contributors.

Functional Tests (7) ---------------------------------------------------------------------------------------------------
Modules: Filesystem, Yii2
------------------------------------------------------------------------------------------------------------------------

Fatal error: Uncaught TypeError: Argument 1 passed to PHPUnit_Framework_TestResult::setCodeCoverage() must be an instance of SebastianBergmann\CodeCoverage\CodeCoverage, instance of Codeception\Coverage\DummyCodeCoverage given, called in C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php on line 78 and defined in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php on line 941

TypeError: Argument 1 passed to PHPUnit_Framework_TestResult::setCodeCoverage() must be an instance of SebastianBergmann\CodeCoverage\CodeCoverage, instance of Codeception\Coverage\DummyCodeCoverage given, called in C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php on line 78 in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php on line 941

Call Stack:
    0.0007     361488   1. {main}() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:0
    0.1926    4867336   2. Codeception\Application->run() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:33
    0.1926    4867336   3. Symfony\Component\Console\Application->run() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Application.php:103
    0.2031    5076800   4. Symfony\Component\Console\Application->doRun() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\symfony\console\Application.php:118
    0.2036    5076800   5. Symfony\Component\Console\Application->doRunCommand() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\symfony\console\Application.php:187
    0.2037    5076800   6. Symfony\Component\Console\Command\Command->run() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\symfony\console\Application.php:820
    0.2101    5078704   7. Codeception\Command\Run->execute() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\symfony\console\Command\Command.php:256
    0.3585    6243904   8. Codeception\Command\Run->runSuites() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Command\Run.php:286
    0.3585    6243904   9. Codeception\Codecept->run() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Command\Run.php:359
    0.3730    6245576  10. Codeception\Codecept->runSuite() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Codecept.php:178
    0.5131    7806240  11. Codeception\SuiteManager->run() C:\Users\davidgro鈻抏\AppData\Roaming\Composer\vendor\codeception\codeception\src\Codeception\Codecept.php:209
    0.5151    7820904  12. Symfony\Component\EventDispatcher\EventDispatcher->dispatch() C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\SuiteManager.php:161
    0.5151    7821200  13. Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() C:\xampp\htdocs\hydra\vendor\symfony\event-dispatcher\EventDispatcher.php:43
    0.5273    7840280  14. call_user_func:{C:\xampp\htdocs\hydra\vendor\symfony\event-dispatcher\EventDispatcher.php:174}() C:\xampp\htdocs\hydra\vendor\symfony\event-dispatcher\EventDispatcher.php:174
    0.5273    7840280  15. Codeception\Coverage\Subscriber\Local->beforeSuite() C:\xampp\htdocs\hydra\vendor\symfony\event-dispatcher\EventDispatcher.php:174
    0.5277    7841304  16. Codeception\Coverage\SuiteSubscriber->applyFilter() C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\Subscriber\Local.php:37
    0.5291    7846224  17. PHPUnit_Framework_TestResult->setCodeCoverage() C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php:78




FATAL ERROR. TESTS NOT FINISHED.
Uncaught TypeError: Argument 1 passed to PHPUnit_Framework_TestResult::setCodeCoverage() must be an instance of SebastianBergmann\CodeCoverage\CodeCoverage, instance of Codeception\Coverage\DummyCodeCoverage given, called in C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php on line 78 and defined in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php:941
Stack trace:
#0 C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php(78): PHPUnit_Framework_TestResult->setCodeCoverage(Object(Codeception\Coverage\DummyCodeCoverage))
#1 C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\Subscriber\Local.php(37): Codeception\Coverage\SuiteSubscriber->applyFilter(Object(PHPUnit_Framework_TestResult))
#2 [internal function]: Codeception\Coverage\Subscriber\Local->beforeSuite(Object(Codeception\Event\SuiteEvent), 'suite.before', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 C:\xampp\htdocs\hyd
in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php:941
PHP Fatal error:  Uncaught TypeError: Argument 1 passed to PHPUnit_Framework_TestResult::setCodeCoverage() must be an instance of SebastianBergmann\CodeCoverage\CodeCoverage, instance of Codeception\Coverage\DummyCodeCoverage given, called in C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php on line 78 and defined in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php:941
Stack trace:
#0 C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\SuiteSubscriber.php(78): PHPUnit_Framework_TestResult->setCodeCoverage(Object(Codeception\Coverage\DummyCodeCoverage))
#1 C:\xampp\htdocs\hydra\vendor\codeception\base\src\Codeception\Coverage\Subscriber\Local.php(37): Codeception\Coverage\SuiteSubscriber->applyFilter(Object(PHPUnit_Framework_TestResult))
#2 [internal function]: Codeception\Coverage\Subscriber\Local->beforeSuite(Object(Codeception\Event\SuiteEvent), 'suite.before', Object(Symfony\Component\EventDispatcher\EventDispatcher))
#3 C:\xampp\htdocs\hyd in C:\xampp\htdocs\hydra\vendor\phpunit\phpunit\src\Framework\TestResult.php on line 941

Additional info

| Q | A
| ---------------- | ---
| Yii version | 2.0.11
| PHP version | 7
| Operating system | Windows 10

Are there any known incompatibilites between the Codeception/PHPUnit version?

I found https://github.com/sebastianbergmann/php-code-coverage/issues/444 which could be related to this issue. According to Bergmann, this problem is on the codeception side.

Is there anyone else encountering this problem? Thanks a lot.

question

Most helpful comment

You are absolutely correct. For people encountering this: I solved the problem. You need to assure that the globally installed version is compatible with the phpunit version inside the project you are working on. I did the following:

composer global require "codeception/codeception=dev-master"
composer global require "codeception/specify=dev-master"
composer global require "codeception/verify=dev-master"

followed by the same in the project directory:

composer require "codeception/codeception=dev-master"
composer require "codeception/specify=dev-master"
composer require "codeception/verify=dev-master"

which made the versions compatible. Everything is working fine now.

All 3 comments

I dont see any link to Yii in your stacktrace. This is a Yii2 issue tracker you know ;)

Thank you for your question.
In order for this issue tracker to be effective, it should only contain bug reports and feature requests.

We advise you to use our community driven resources:

If you are confident that there is a bug in the framework, feel free to provide information on how to reproduce it. This issue will be closed for now.

_This is an automated comment, triggered by adding the label question._

You are absolutely correct. For people encountering this: I solved the problem. You need to assure that the globally installed version is compatible with the phpunit version inside the project you are working on. I did the following:

composer global require "codeception/codeception=dev-master"
composer global require "codeception/specify=dev-master"
composer global require "codeception/verify=dev-master"

followed by the same in the project directory:

composer require "codeception/codeception=dev-master"
composer require "codeception/specify=dev-master"
composer require "codeception/verify=dev-master"

which made the versions compatible. Everything is working fine now.

Was this page helpful?
0 / 5 - 0 ratings