Codeception icon indicating copy to clipboard operation
Codeception copied to clipboard

Codeception Error with Coverage after Update to Codeception 5.0.0

Open OwnerOfThisIsle opened this issue 3 years ago • 5 comments

What are you trying to achieve?

Very similar to https://github.com/Codeception/Codeception/issues/6519: When I do codecept run everything is green, but when I do codecept run --coverage I get an error. The exakt output is below. There is also a file _output\App.Tests.Acceptance.HomepageCest.testIndexPage.fail.html, that only consists of on error message:

<html><head></head><body><br>
<b>Fatal error</b>:  Uncaught ErrorException: Warning: Cannot modify header information - headers already sent in D:\Apps\Apache\DSCA\c3.php:52
Stack trace:
#0 D:\Apps\Apache\DSCA\c3.php(264): __c3_error()
#1 D:\Apps\Apache\DSCA\c3.php(390): __c3_factory()
#2 [internal function]: {closure}()
#3 {main}
  thrown in <b>D:\Apps\Apache\DSCA\c3.php</b> on line <b>52</b><br>
</body></html>

What do you get instead?

Provide console output if related. Use -vvv mode for more details.

D:\Apps\Apache\DSCA>codecept run tests\acceptance\HomepageCest.php --coverage -vvv

==== Redirecting to Composer-installed version in vendor/codeception. You can skip this using --no-redirect ====
Codeception PHP Testing Framework v5.0.0 https://helpukrainewin.org

App\Tests.acceptance Tests (1) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------Modules: WebDriver, \App\Tests\Helper\Acceptance, Asserts, \Sanitas\TestHelper\Module\ConfigHelper
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------⏺ Recording ⏺ step-by-step screenshots will be saved to D:\Apps\Apache\DSCA\tests/_output</info>
Directory Format: record_62e930a5cdfb5_{filename}_{testname} ----
HomepageCest: Test index page
Signature: App\Tests\Acceptance\HomepageCest:testIndexPage
Test: tests\acceptance\HomepageCest.php:testIndexPage
Scenario --
  [GET] http://127.0.0.1:2777/
  [Cookies] [{"name":"CODECEPTION_CODECOVERAGE","value":"{\"CodeCoverage\":\"testIndexPage\",\"CodeCoverage_Suite\":\"App\\\\Tests.acceptance\",\"CodeCoverage_Config\":null}","path":"/","domain":"127.0.0.1","expiry":1659535913,"secure":false,"httpOnly":false}]
 I am on page "/"
  [GET] http://127.0.0.1:2777/
  [Cookies] [{"name":"CODECEPTION_CODECOVERAGE","value":"{\"CodeCoverage\":\"testIndexPage\",\"CodeCoverage_Suite\":\"App\\\\Tests.acceptance\",\"CodeCoverage_Config\":null}","path":"/","domain":"127.0.0.1","expiry":1659535913,"secure":false,"httpOnly":false}]
  Screenshot and page source were saved into 'D:\Apps\Apache\DSCA\tests/_output\' dir
 ERROR 


In LocalServer.php line 163:

  [RuntimeException]
  Code coverage file D:\Apps\Apache\DSCA\tests/_output\c3tmp/codecoverage.serialized does not exist  


Exception trace:
  at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\Coverage\Subscriber\LocalServer.php:163
 Codeception\Coverage\Subscriber\LocalServer->afterSuite() at D:\Apps\Apache\DSCA\vendor\symfony\event-dispatcher\EventDispatcher.php:230
 Symfony\Component\EventDispatcher\EventDispatcher->callListeners() at D:\Apps\Apache\DSCA\vendor\symfony\event-dispatcher\EventDispatcher.php:59
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\SuiteManager.php:150
 Codeception\SuiteManager->run() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\Codecept.php:260
 Codeception\Codecept->runSuite() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\Codecept.php:216
 Codeception\Codecept->run() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\Command\Run.php:442
 Codeception\Command\Run->execute() at D:\Apps\Apache\DSCA\vendor\symfony\console\Command\Command.php:298
 Symfony\Component\Console\Command\Command->run() at D:\Apps\Apache\DSCA\vendor\symfony\console\Application.php:1024
 Symfony\Component\Console\Application->doRunCommand() at D:\Apps\Apache\DSCA\vendor\symfony\console\Application.php:299
 Symfony\Component\Console\Application->doRun() at D:\Apps\Apache\DSCA\vendor\symfony\console\Application.php:171
 Symfony\Component\Console\Application->run() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\src\Codeception\Application.php:112
 Codeception\Application->run() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\app.php:45
 {closure}() at D:\Apps\Apache\DSCA\vendor\codeception\codeception\app.php:46
 require() at C:\Users\p.garstenauer\AppData\Roaming\Composer\vendor\codeception\codeception\autoload.php:13
 require_once() at C:\Users\p.garstenauer\AppData\Roaming\Composer\vendor\codeception\codeception\app.php:3
 require() at C:\Users\p.garstenauer\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:7

run [-o|--override OVERRIDE] [-e|--ext EXT] [--report] [--html [HTML]] [--xml [XML]] [--phpunit-xml [PHPUNIT-XML]] [--colors] [--no-colors] [--silent] [--steps] [-d|--debug] [--shard SHARD] [--filter FILTER] [--grep GREP] [--bootstrap [BOOTSTRAP]] [--no-redirect] [--coverage [COVERAGE]] [--coverage-html [COVERAGE-HTML]] [--coverage-xml [COVERAGE-XML]] [--coverage-text [COVERAGE-TEXT]] [--coverage-crap4j [COVERAGE-CRAP4J]] [--coverage-cobertura [COVERAGE-COBERTURA]] [--coverage-phpunit [COVERAGE-PHPUNIT]] [--no-exit] [-g|--group GROUP] [-s|--skip SKIP] [-x|--skip-group SKIP-GROUP] [--env ENV] [-f|--fail-fast [FAIL-FAST]] [--no-rebuild] [--seed SEED] [--no-artifacts] [--] [<suite> [<test>]]

Details

  • Codeception version: 5.0.0
  • PHP Version: 8.0.10
  • Operating System: Windows
  • Installation type: Composer
  • List of installed packages (composer show)
  • Suite configuration:
actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'http://127.0.0.1:2777/'
            browser: chrome
            window_size: 976x636
            capabilities:
                "acceptInsecureCerts": true
                "goog:chromeOptions":
                    args: ["--headless", "--disable-gpu", "--disable-extensions"]
        - \App\Tests\Helper\Acceptance
        - Asserts
        - \Sanitas\TestHelper\Module\ConfigHelper
extensions:
    enabled:
        - Codeception\Extension\Recorder:
            delete_successful: true

OwnerOfThisIsle avatar Aug 02 '22 14:08 OwnerOfThisIsle

After re-reading the "Cannot modify header" message, I thought this could be relevant as well:

After upgrading to symfony 5, it was not straight forward to find the correct place for c3.php in index.php. This is what we have in the moment:

<?php

use App\Kernel;

require_once dirname(__DIR__) . '/vendor/autoload_runtime.php';

return function (array $context) {
    // Disable codeception code coverage in the production environment
    if ($_SERVER['APP_ENV'] !== 'prod') {
        require dirname(__DIR__) . '/c3.php';
    }

    return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};

OwnerOfThisIsle avatar Aug 02 '22 15:08 OwnerOfThisIsle

So the root cause is that something prints <html><head></head><body><br>. I don't think that it is Codeception fault.

Naktibalda avatar Aug 02 '22 15:08 Naktibalda

I raised pull request to fix headers already sent warning.

But it was a secondary error, you have problem with suite settings as well. You can find error message in the log file, or replace __c3_error() call with die($e->getMessage()); and read it from fail.html file. https://github.com/Codeception/c3/blob/a4469a97416c79edece89fb8344ff0b134f3eef9/c3.php#L264

Naktibalda avatar Aug 02 '22 16:08 Naktibalda

Thx for the input. Ok. I tried the die(). My fail.html now holds: <html><head></head><body>Suite .acceptance was not loaded</body></html>

Don't know what to make of it. In https://github.com/Codeception/Codeception/issues/6519 you mentioned namespace setting.

I have this in my codeception.yaml: namespace: App\Tests

Anything wrong with that?

OwnerOfThisIsle avatar Aug 02 '22 16:08 OwnerOfThisIsle

It is on my todo list to debug this issue.

Naktibalda avatar Aug 07 '22 11:08 Naktibalda

Just redid the update to codecept 5 and can confirm that this is solved. Sorry for the late feedback. Keep up the good work!

OwnerOfThisIsle avatar Nov 04 '22 07:11 OwnerOfThisIsle