Codeception / c3

Remote CodeCoverage for Codeception. Part of Codeception testing framework.
http://codeception.com
71 stars 46 forks source link

Don't work with suite configuration #50

Closed komandakycto closed 5 years ago

komandakycto commented 5 years ago

I try run coverage count by command:

php vendor/bin/codecept run -c api --debug --coverage

And nothing work. I see in Response error: Notice: Undefined variable: settings in /var/www/html/c3.php on line 249 If I parse Exception on 241 line I see message: "Suite api was not loaded" because self::suites is empty in vendor/codeception/base/src/Codeception/Configuration.php:307.

When s3.php run \Codeception\Configuration::suiteSettings($suite, \Codeception\Configuration::config()) without configuration file we see that config method return self::$config and don't run self::loadSuites(); below. It is cause why I see that my suit was not loaded.

My composer versions:, "codeception/base": "^2.2.3", "codeception/verify": "~0.3.1", "phpunit/phpunit": "5.7.27", "codeception/c3": "2.*"

My project structure -root ---api ----tests ------api/ ------functional/ ------unit/ ------api.suite.yml ------functional.suite.yml ------unit.suite.yml ----codeception.yml --backend/ --common/ -codeception.yml

Naktibalda commented 5 years ago

\Codeception\Configuration::config() runs self::loadSuites(); right before return $config;

komandakycto commented 5 years ago

In s3.php in __c3_factory() function run \Codeception\Configuration::config() and load global config. In config() function execute only first lines:

if (!$configFile && self::$config) {
       return self::$config;
}
komandakycto commented 5 years ago

In vendor/codeception/base/src/Codeception/Configuration.php self::loadSuites() calls in the end of config() method. How self::$suites should be fill if config() method return self::config in the first lines of config() method?

Naktibalda commented 5 years ago

It returns cached result if config method is called multiple times.

Naktibalda commented 5 years ago

The only way to get config without suites is if you include setting is present and paths: tests: is missing in codeception.yml. https://github.com/Codeception/base/blob/2.2.3/src/Codeception/Configuration.php#L183-L184

Which is quite likely with your directory structure.

komandakycto commented 5 years ago

Thanks, it was cause of exception like "Suite api was not loaded". But after fix, I catch another error =)