Codeception: Trait not found when using @runInSeparateProcess

Created on 30 Sep 2016  路  5Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

I'm trying to use PHPUnit @runInSeparateProcess to run a test in a separate process, I don't know if Codeception supports it.

What do you get instead?

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

 [PHPUnit_Framework_Exception] PHP Fatal error:  Trait '_generated\UnitTesterActions' not found in /Users/pamela/Sites/interadmin-orm-sample/tests/_support/UnitTester.php on line 23
Fatal error: Trait '_generated\UnitTesterActions' not found in /Users/pamela/Sites/interadmin-orm-sample/tests/_support/UnitTester.php on line 23  

Provide test source code if related

// paste test

Details

  • Codeception version: 2.2
  • PHP Version: 7.0.10
  • Operating System: OS X El Capitan (10.11.6)
  • Installation type: Composer
  • List of installed packages (composer show)
adodb/adodb-php                    v5.20.7 ADOdb is a PHP database abstraction layer library
behat/gherkin                      v4.4.4  Gherkin DSL parser for PHP 5.3
codeception/codeception            2.2.5   BDD-style testing framework
doctrine/inflector                 v1.1.0  Common String Manipulations with regard to casing and singular/plural rules.
doctrine/instantiator              1.0.5   A small, lightweight utility to instantiate objects in PHP without invoking their constructors
facebook/webdriver                 1.1.3   A PHP client for WebDriver
filp/whoops                        2.0.0   php error handling for cool kids
guzzlehttp/guzzle                  6.2.1   Guzzle is a PHP HTTP client library
guzzlehttp/promises                1.2.0   Guzzle promises library
guzzlehttp/psr7                    1.3.1   PSR-7 message implementation
illuminate/cache                   v5.3.4  The Illuminate Cache package.
illuminate/config                  v5.3.4  The Illuminate Config package.
illuminate/container               v5.3.4  The Illuminate Container package.
illuminate/contracts               v5.3.4  The Illuminate Contracts package.
illuminate/database                v5.3.4  The Illuminate Database package.
illuminate/filesystem              v5.3.4  The Illuminate Filesystem package.
illuminate/log                     v5.3.4  The Illuminate Log package.
illuminate/support                 v5.3.4  The Illuminate Support package.
jdorn/sql-formatter                v1.2.17 a PHP SQL highlighting library
league/flysystem                   1.0.27  Filesystem abstraction: Many filesystems, one API.
monolog/monolog                    1.21.0  Sends your logs to files, sockets, inboxes, databases and various web services
myclabs/deep-copy                  1.5.4   Create deep copies (clones) of your objects
nesbot/carbon                      1.21.0  A simple API extension for DateTime.
paragonie/random_compat            v2.0.2  PHP 5.x polyfill for random_bytes() and random_int() from PHP 7
phpdocumentor/reflection-common    1.0     Common reflection classes used by phpdocumentor to reflect the code structure
phpdocumentor/reflection-docblock  3.1.0   With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is emb...
phpdocumentor/type-resolver        0.2     
phpspec/prophecy                   v1.6.1  Highly opinionated mocking framework for PHP 5.3+
phpunit/php-code-coverage          4.0.1   Library that provides collection, processing, and rendering functionality for PHP code coverage information.
phpunit/php-file-iterator          1.4.1   FilterIterator implementation that filters files based on a list of suffixes.
phpunit/php-text-template          1.2.1   Simple template engine.
phpunit/php-timer                  1.0.8   Utility class for timing
phpunit/php-token-stream           1.4.8   Wrapper around PHP's tokenizer extension.
phpunit/phpunit                    5.5.5   The PHP Unit Testing framework.
phpunit/phpunit-mock-objects       3.2.7   Mock Object library for PHPUnit
psr/http-message                   1.0.1   Common interface for HTTP messages
psr/log                            1.0.1   Common interface for logging libraries
sebastian/code-unit-reverse-lookup 1.0.0   Looks up which function or method a line of code belongs to
sebastian/comparator               1.2.0   Provides the functionality to compare PHP values for equality
sebastian/diff                     1.4.1   Diff implementation
sebastian/environment              1.3.8   Provides functionality to handle HHVM/PHP environments
sebastian/exporter                 1.2.2   Provides the functionality to export PHP variables for visualization
sebastian/global-state             1.1.1   Snapshotting of global state
sebastian/object-enumerator        1.0.0   Traverses array structures and object graphs to enumerate all referenced objects
sebastian/recursion-context        1.0.2   Provides functionality to recursively process PHP variables
sebastian/resource-operations      1.0.0   Provides a list of PHP built-in functions that operate on resources
sebastian/version                  2.0.0   Library that helps with managing the version number of Git-hosted PHP projects
symfony/browser-kit                v3.1.4  Symfony BrowserKit Component
symfony/console                    v3.1.4  Symfony Console Component
symfony/css-selector               v3.1.4  Symfony CssSelector Component
symfony/dom-crawler                v3.1.4  Symfony DomCrawler Component
symfony/event-dispatcher           v3.1.4  Symfony EventDispatcher Component
symfony/finder                     v3.1.4  Symfony Finder Component
symfony/polyfill-mbstring          v1.2.0  Symfony polyfill for the Mbstring extension
symfony/translation                v3.1.4  Symfony Translation Component
symfony/var-dumper                 v3.0.9  Symfony mechanism for exploring and dumping PHP variables
symfony/yaml                       v3.1.4  Symfony Yaml Component
webmozart/assert                   1.1.0   Assertions to validate method input/output with nice error messages.
  • Suite configuration:
# Codeception Test Suite Configuration
#
# Suite for unit (internal) tests.

class_name: UnitTester
modules:
    enabled:
        - Asserts
        - Db
        - \Helper\Unit
    config:
        Db:
            dsn: 'mysql:host=localhost;dbname=interadmin_orm_tests'
            user: '***'
            password: '***'
            dump: tests/_data/dump.sql

All 5 comments

I'm trying to use PHPUnit @runInSeparateProcess to run a test in a separate process, I don't know if Codeception supports it.

No.

Current PHP and PHPUnit implementation of this behavior are pretty complex and unstable. That's why I'd not use it. By allowing this behavior we will need to rework the codebase to allow concurrent execution which still is not first-class citizen in PHP.

I have the same issue. Using straight PhpUnit with @runInSeparateProcess works just fine. Using CodeCeption doesn't. This therefore indicates that CodeCeption is not, in some way, wrapping PhpUnit in stable/proper fashion

Same here. I have planned to port everything I have to codeception, but there are a lot of tests which requires this separateprocess. :( Sad...

My team and I are using this @runInSeperateProcess annotation to test classes which execute PHPs header in our Code without the need of making a single test suite per test to run their tests together.
I don't think that sending headers with PHP and wanting to test this behaviour automated is something uncommon.

This is a key feature of PHPUnit and should therefore be supported in any framework building on top of PHPUnit which claims to have a kind of compatibility to PHPUnit in my humble opinion.

Best regards.

You are welcome to implement it.

Was this page helpful?
0 / 5 - 0 ratings