4

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 Answers 2

11

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
Sign up to request clarification or add additional context in comments.

1 Comment

Are you able to use Yii2's Fixtures in that way?
6

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.

4 Comments

Thank you for your reply. I've managed to install codeception and run a first acceptance test, but only with official codeception [php composer.phar require "codeception/codeception:*" ] comand instead of those mentioned in yii2 guiide. It has a codeception (and other) directory in my vendor root. Is it correct?
This worked for me but I had to run codecept from the vendor/bin. ../vendor/bin/codecept run I also had to make sure I codeception was installed in my composer, wasn't done as part of yii-codeception
I created a global link for codeception so I can run it from anywhere. You can do that too as it is quite handy.
Like i said in the answer, the last line of the link tells you how to set up codeception globally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.