Codeception run doesn't see the test folder in the root

I wanted to write some functional tests. After exploring several tutorials, running this command (codecept run), example tests which were located in root_folder/tests should be work. However, in my case, it is not running anything. If I write some code in vendor/bin/tests/functional, console is giving me [RuntimeException] Call to undefined method FunctionalTester::amOnPage error or alternatively same error for all methods.

I am using PHP 8.0.0 and YII2 2.0.40.

The Codeception extension executable for the tests will be located at vendor/bin/codecept. So try this:

vendor/bin/codecept run

Your tests should be in the tests folder (that is located in the root folder for the app-basic, or inside each app folder for the app-advanced).

Also, never change the code inside the vendor folder, that is only for composer to change.

1 Like

Thank you for your attention, but I have tried all your steps and no result( It is running 0 files for both types of tests.
I am using the basic template.

Where are your test files located?

Can you provide the output from vendor/bin/codecept run?

1 Like

When my test files are located in the root folder, after giving command vendor/bin/codecept run:


There are some testing files but yii2 is not seeing it.

Codecept is running, but is not finding any tests…

In your first post you told us that you had your tests at vendor/bin/tests/functional, but by looking at your image, it seems that you have the “template” testes in the correct folder and they should be running, unless you’ve changed some configuration file.

Can you start a new project with the:

composer create-project --prefer-dist yiisoft/yii2-app-basic basic

Then enter the folder and execute vendor/bin/codecept run. If tests run without error, copy the tests folder from the newly created project, and run the codecept again in your project.

1 Like

Sorry for the late response! However, your solution also did not work. Then, I tried other ways too. And find this: Example. I replaced bootstrap to run command and it worked) Thank you for your hints!