Codeception / c3

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

codeception/codeception/autoload.php not included #49

Closed mcera closed 3 years ago

mcera commented 6 years ago

What are you trying to achieve?

Create code coverage for acceptance tests.

I'm using Symfony 4.1 and c3.php is included in public/index.php

What do you get instead?

PS C:\Apps\Apache\LPNEW> codecept run acceptance --coverage -vvv

==== Redirecting to Composer-installed version in vendor/codeception ====
Codeception PHP Testing Framework v2.5.0
Powered by PHPUnit 7.3.5 by Sebastian Bergmann and contributors.
Running with seed:

App\Tests.acceptance Tests (2) -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------Modules: WebDriver, \App\Tests\Helper\Acceptance
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
In ErrorHandler.php line 83:

  [PHPUnit\Framework\Exception (2)]
  file_get_contents(http://127.0.0.1:2779/c3/report/clear): failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error

Exception trace:
 Codeception\Subscriber\ErrorHandler->errorHandler() at n/a:n/a
 file_get_contents() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Coverage\Subscriber\LocalServer.php:133
 Codeception\Coverage\Subscriber\LocalServer->c3Request() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Coverage\Subscriber\LocalServer.php:72
 Codeception\Coverage\Subscriber\LocalServer->beforeSuite() at C:\Apps\Apache\LPNEW\vendor\symfony\event-dispatcher\EventDispatcher.php:212
 Symfony\Component\EventDispatcher\EventDispatcher->doDispatch() at C:\Apps\Apache\LPNEW\vendor\symfony\event-dispatcher\EventDispatcher.php:44
 Symfony\Component\EventDispatcher\EventDispatcher->dispatch() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\SuiteManager.php:156
 Codeception\SuiteManager->run() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Codecept.php:191
 Codeception\Codecept->runSuite() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Codecept.php:158
 Codeception\Codecept->run() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Command\Run.php:492
 Codeception\Command\Run->runSuites() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Command\Run.php:387
 Codeception\Command\Run->execute() at C:\Apps\Apache\LPNEW\vendor\symfony\console\Command\Command.php:255
 Symfony\Component\Console\Command\Command->run() at C:\Apps\Apache\LPNEW\vendor\symfony\console\Application.php:886
 Symfony\Component\Console\Application->doRunCommand() at C:\Apps\Apache\LPNEW\vendor\symfony\console\Application.php:262
 Symfony\Component\Console\Application->doRun() at C:\Apps\Apache\LPNEW\vendor\symfony\console\Application.php:145
 Symfony\Component\Console\Application->run() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\src\Codeception\Application.php:108
 Codeception\Application->run() at C:\Apps\Apache\LPNEW\vendor\codeception\codeception\package\bin:38
 require() at C:\Users\m.cerovic\AppData\Roaming\Composer\vendor\codeception\codeception\autoload.php:12
 require_once() at C:\Users\m.cerovic\AppData\Roaming\Composer\vendor\codeception\codeception\codecept:7

Details

codeception.yml:

namespace: App\Tests
paths:
    tests: tests
    output: tests/_output
    data: tests/_data
    support: tests/_support
    envs: tests/_envs
actor_suffix: Tester
extensions:
    enabled:
        - Codeception\Extension\RunFailed
coverage:
    enabled: true
    remote: true
    include:
        - src/*
    exclude:
        - src/Kernel.php
params:
    - .env

acceptance.suite.yml:

actor: AcceptanceTester
modules:
    enabled:
        - WebDriver:
            url: 'http://127.0.0.1:2779'
            browser: chrome
            window_size: 976x636
        - \App\Tests\Helper\Acceptance
extensions:
    enabled:
        - Codeception\Extension\Recorder:
            delete_successful: true
mcera commented 6 years ago

Workaround: Before you include c3.php in public/index.php you need to require codeception/autoload.php

Why is codeception/autoload.php not added to composer autoload_files.php?

OwnerOfThisIsle commented 5 years ago

I experienced the same issue in Codeception 3.1, the workaround still works! Thx man you are awsome..

Naktibalda commented 3 years ago

This is the same issue as #67, explicitly requiring codeception/autoload.php is only necessary if vendor/autoload.php file is included before c3.php file. I raised #68 to fix this issue.

In Codeception 5.0, codecept functions will be loaded by composer automatically, so workaround won't be necessary.