Codeception / Codeception

Full-stack testing PHP framework
http://codeception.com
MIT License
4.77k stars 1.3k forks source link

Cyclic @depends runs out of memory #5318

Open leonardor opened 5 years ago

leonardor commented 5 years ago

I try to run codecept.phar version 2.5.1 with -g flag to select only the tests I am interested in to run.

After I run the command like that:

php codecept.phar run functional -g group_name -vvv --debug

and it just outputs this after a long time:

Codeception PHP Testing Framework v2.5.1
Powered by PHPUnit 5.7.27 by Sebastian Bergmann and contributors.
Running with seed:

[Groups] group_name
PHP Fatal error:  Allowed memory size of 1073741824 bytes exhausted (tried to al
locate 262144 bytes) in phar://C:/workspace/laravel/workbench/application/codecept.phar/src/Codeception/Test/Cest.php on line 160

There are 48 files in the functional suite folder and as far as I understand it first parses the annotations of all tests and then identifies the groups, and at one point it gets stuck at one test and method in particular.

I tried to remove one by one the test files and see which causes the problem and I have identified it. There is a test which has a method that is 51 characters long. If I remove one character and if its name fits exactly 50 characters long the suite runs perfectly.

I can't figure out if this is a Codeception problem of a PHPUnit problem.

available:

* Suite configuration:

```yml
class_name: FunctionalTester
settings:
    bootstrap: _bootstrap.php
modules:
    enabled:
        - \Helper\Functional
        - Asserts
        - Cli
        - PhpBrowser:
            url: http://some_url
        - REST:
            depends: PhpBrowser
            part: Json
groups:
    # add all tests from a directory to api group
    frontend: [tests/functional/frontend]
    backend: [tests/functional/backend]

env:
    frontend:
        modules:
            config:
                PhpBrowser:
                    url: http://some_url
                    curl:
                        CURLOPT_TIMEOUT: 10
                REST:
                    depends: PhpBrowser
                    part: Json
                    timeout: 10
    backend:
        modules:
            config:
                PhpBrowser:
                    url: http://some_url
                    curl:
                        CURLOPT_TIMEOUT: 10
                REST:
                    depends: PhpBrowser
                    part: Json
                    timeout: 10
leonardor commented 5 years ago

I have identified the real cause. That long method @depends on a previous method that also @depends on a method that should run after these two so there was a loop; the renaming just broke the chain of dependencies. Is there a validator that can identify when the chain of dependencies is broken?

Thank you!