How To Run Tests In Advanced And Basic Templates ?

As the topic title says, how can we run tests that already exists in basic and advanced templates ? I am especially interested in how to run tests in advanced template, since that template is very fragmented; frontend, backend, common… How to run all these tests ? In Laravel after you install codeception using composer, you would just run


vendor/bin/codecept run

Or if you have codeception globaly installed


codecept run

from the root of your application. That does not work with yii2, and I red that testing works out of box with yii2. Also, where do we specify testing configuration ? Like testing database ? In Laravel, you would have testing configuration files, and Laravel would use them automaticaly when you run tests. How to set up and use testing configuration in yii2 ? In advanced application you can set up development or production environments, I do not know what to do to set up testing one… And to be honest I do not understand how dev. and prod. environments work in yii2, I just see that some config files exists in like 5 different places, and do not know which ones to use. Any help please ? Thanks

For basic it’s “codecept run”, for advanced it’s the same but we have separate tests for frontend, backend etc. so you should cd there first.

It says : codecept: command not found.

Do you have codeception installed globaly on your machine ? If you do, which version is recomended to be used with yii2 ? latest ?

Ok, here is the thing. First you need codeception installed globally. Next you will have to install additional packages using composer, like Specify and Verify. Next you will have to rebuild codecept using


codecept build

command. After that you need to install 3 databases that advanced yii2 app is using for testing. Readme file will tell you that you have to migrate databases in every test suite of your application, but that does not work. You can try to migrate standart yii database migration inside test databases, I have done that. But next problem comes that acceptance test will fail with message “I am on page “/advanced/frontend/web/index-test.php?r=site%2Fsignup””. And I don’t know what to do with this. Now I am just wandering, howcome using codeception to test baceme so complicated in yii :o. I give up, this is just a mess.

Yeah, it’s all documented: http://stuff.cebe.cc/yii2docs/guide-test-overview.html

I tried twice with the basic-app-template but codecept does not work.

"concept run" returns

"Configuration file could not be found.

Run bootstrap to initialize Codeception."

After running "concept bootstrap" "concept run" returns

Acceptance Tests (0)

Functional Tests (0)

Unit Tests (0)

"concept bootstrap" is not mentioned in the yii2 guide, so what´s wrong?

Where is the config file and how to configure the config file?

It works! I had to run "codecept build"…

But there is something wrong with the output/font, have a look at the screenshot:

6057

cmdtests.png

–no-ansi does not help

Try running it via git console. You’ll get all the fancy colors etc.