Codeception: Trait '_generated/*TesterActions' not found

Created on 11 Jun 2018  路  18Comments  路  Source: Codeception/Codeception

What are you trying to achieve?

Im trying to run a test,

What do you get instead?

Im suddenly getting this error Trait '_generated/*TesterActions' not found.

Details

When I go look under _generated the file *TesterActions is still there but its empty.
It happens when codeception tries to rebuild the class.

  • Codeception version: 2.2.10
  • PHP Version: 7.0
  • Operating System: Windows 10 / Vagrant
  • Installation type: Composer
class_name: SomeTestTester
modules:
    enabled:
        - REST:
            url: https://domain.com/api
            depends: PhpBrowser
            part: Json
        - \Helper\ConfiguratorHelper
        - Db
        - Asserts

I have the feeling that it has something to do Line seperation between windows and linux
but im not sure.

Most helpful comment

Yes, that was the reason that I ran codecept build

All 18 comments

I found that I had the same issue. Whenever I ran codecept run <test> or codecept build the contents of the AcceptanceTesterActions file was deleted, resulting in an error from the file in which it was used.

I have a similar setup to the one you described above:

Codecept version: 2.4.1
PHP Version: 5.6
Operating System: Windows 10 / Vagrant
Installation type: Composer

Confusingly the issue went away when I restarted my physical machine (rather than the virtual machine). As far as I can tell I did not change anything else between the restart and the running of the tests. I wish I could offer more help on this issue as I have experienced this problem before, but can't remember how it was resolved before!

did you run codecept build in order to re-generate the helpers and traits?

Yes, that was the reason that I ran codecept build

Very mysterious issue. Looks like it's somehow related to Vagrant and Windows. Unfortunately, I don't use either of them so I don't think I can reproduce or fix it. Could you try to investigate it further?

Im using --no-rebuild to bypass this issue but would really love to know what the real cause is.

I suspect it has something to do with LF for linux line breaks and CRLF for windows line breaks
because I recently installed git again and something got messed up with my line breaks after which the issue started to occur unfortunately I didn't have time to investigate it deeper.

Hello, I have the same issue I put a namespace and run build but the codeception cannot find my trait.

Ditto. Probably different error, same result: for me, using @runTestsInSeparateProcesses annotation for a unit test results in:

  [PHPUnit\Framework\Exception] Fatal error: Trait '_generated\UnitTesterActions' not found in .../tests/_support/UnitTester.php on line 21

do we have the fix? I got the same issues on 2.5.x version

Same seems to happen on run.

Imo run should never rebuild anything. But it does when multiple envs are used for example. See https://github.com/Codeception/Codeception/issues/5500

We have this issue on macOS so this is not a platform specific issue.

I'm experiencing the same issue with v3.1.0 (Windows 10 & Ubuntu 18). Any work-around or solution available?

same issue

Same error. More than year Codeception can't fix it?

It's not the issue of codeception, it's just issue with autoload, just read this https://getcomposer.org/doc/04-schema.md#autoload

It's not the issue of codeception, it's just issue with autoload, just read this https://getcomposer.org/doc/04-schema.md#autoload

Afaik this is not an autoload issue and also happens with a phar and normal setups which use a normal composer setup with a working autoloader.

I had a sort of workaround, codeception prepends '_support' prefix directory for that class, so I changed '_support' dir settings to './' in codeception.yml, and the class was found, though I had tests in the root directory './', when I changed it to 'tests' - the default, it was somehow found along despite _support prefix. But along I had some other issue an incorrect number of parameters passed to Cest.php so I removed all codeception.yml files I had in any directory if it could be related to the first problem, and it removed also the second problem.

Edit: the second problem though after investigation might be due to having tests and vendor in the root directory, considers also tests parent Cest.php being a test, thus the tests cannot be at the vendor dir level

Turns out this indeed is autoloading issue. To confirm this I've first simply tried to add require_once('/path/to/trait/AcceptanceTesterActions.php'); to AcceptanceTester class.. and it worked.

The solution for us was to add this line to the global _bootstrap.php file.

\Codeception\Util\Autoload::addNamespace('_generated', YOUR_ROOT_DIR . '/path/to/tests/_support/_generated/');

Hope this helps.

I have this error too, but it's not solved with autoloading or the solution provided by @tomolas

It happens as soon as I add a module in my suite config file, the trait generated is an empty file.

(codeception v. 4.0.2)

It oddly disappeared after rebooting my computer.

Was this page helpful?
0 / 5 - 0 ratings