4

I'm new to the Codeception framework and trying to run the unit test scripts from this directory:

tests/codeception/frontend/unit

DB configuration for testing has been done in config-local.php.

Now, my question is how to run the test scripts? I've tried to run the following commands from the terminal:

frontend tests
cd frontend
codecept build
codecept run

But it says Codecept: command not found.

0

2 Answers 2

8

Install Codeception via composer:

$ composer require "codeception/codeception"

From now on Codeception (with installed PHPUnit) can be run as:

$ php vendor/bin/codecept

Next, initialize your testing environment:

$ php vendor/bin/codecept bootstrap

Finally, run the following commands from the yii2 tests/codeception/frontend folder:

$ php vendor/bin/codecept build
$ php vendor/bin/codecept run

Follow this Quickstart Guide to read more about Codeception installation process.

Important note: if you want codecept command to work from the command line:

codecept bootstrap
codecept run

... then you need to configure the $PATH variable properly.

Sign up to request clarification or add additional context in comments.

Comments

0

The fallowing examples need installation codecept globally. This method work for the current user and linux systems.

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

You can set new path $PATH: in /home/user/.bashrc

export PATH="$PATH:/home/user/.config/composer/vendor/bin"

or set alias in .bashrc

alias codecept="/home/user/.config/composer/vendor/bin/codecept"

Now you can use simply

codecept build
codecept run

Comments

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.