4
votes

I'm writing this because yii2 official documentation is still not complete and codeception documentation itself refer to yii2 official docs..:).

I have some questions:

  • In my yii2 app root there is a directory "tests/codeception", this means that codeception is already installed in my project?
  • in vendor/yiisoft there is another codeception directory "yii2-codeception" what is it?
  • the documentation say to create a yii2_basic_tests database and to run a migration, but migration script create only a "migration" table, is it correct?
  • the integration with yii2 provide some web interface or I must run the tests from console scripts?

Someone can explain me how to install and configure codeception in yii2 basic app step by step?

Thank you

Alessandro

2

2 Answers

11
votes

I am doing some like that:

composer global require "codeception/codeception=2.0.*" "codeception/specify=*" "codeception/verify=*"

And next:

ln -s ~/.composer/vendor/bin/codecept /usr/local/bin/codecept

Then I am available to do globally

codecept run
6
votes

First make sure you read this a couple of times http://www.yiiframework.com/doc-2.0/guide-test-environment-setup.html

Afterwards the actual tests are easy to set up. Make sure you make the codecept command work like it says on the last line of the link above. After you install an Yii app you have to go to the tests folder and run

codecept build

to initialise the tests. Then run

codecept run

to run the actual tests.

You can run

codecept run --coverage-html

to get the code coverage for your project.

I have never got the acceptance testing working with code coverage but I got acceptance working without coverage and unit&functional with coverage.