Installing and Using Codecept, Testing suite for PHP

Installing Codecept through Composer it’s fairly easy just make sure to update your composer.json file and add the following code in the require-dev object

"require-dev": {
"codeception/codeception": "~2.0"

And do a composer update.

Check that you have the command to use it. If you have after entering the command it should list all the available commands.

The next thing to do it’s initialize it.
vendor/bin/codecept bootstrap

The command will create a directory structure for your tests if you want to change the route for this just update the codeception.yml file.

Now under it’s file structure it will contain 3 configuration files for the tests.


Those files contains the modules that codecept will use under each suite. By default it only contains the Filesystem and the FunctionalHelper modules.
How I’m working with laravel it will be ok to add the Laravel4 and the Asserts modules. Make sure if you edit this files to run the command to update it.
vendor/bin/codecept build

To create a new testing file just run the command for the suite that you want to use.
vendor/bin/codecept generate:cept functional [NAME_OF_THE_TEST]

Now you’re able to create a “fast” test for your application.

If you are using Laravel like me take in account that if you run a test it will set the environment to “testing” so make sure that you have your configurations setted.

I know this it’s not a full guide to do the tests but you can check for the commands available to you in the official documentation, or if you want you can watch this video it’s from LaraCasts so you need to pay, but it will be the best money spend ever!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s