Quickstart Guide

Codeception PHP Testing Framework is designed to work just out of the box. This means its installation requires minimal steps and no external dependencies preinstalled (except PHP, of course). Only one configuration step should be taken and you are ready to test your web application from an eye of actual user.

Requirements: PHP5.3, CURL enabled

1. Download

Install via Composer

$ composer require "codeception/codeception"  // ./vendor/bin/codecept

$ alias codecept='./vendor/bin/codecept'

Install PHAR locally

$ wget 
$ wget // PHP 5.4 and 5.5download 

$ alias codecept='codecept.phar'

Install PHAR globally

sudo curl -LsS -o /usr/local/bin/codecept
sudo chmod a+x /usr/local/bin/codecept

$ codecept

Alternative Installations

2. Install


codecept bootstrap

This creates codeception.yml file and tests directory.

3. Create Test

Generate your first acceptance test. Acceptance tests emulate behavior of a real user visiting your site.

codecept generate:cept acceptance Welcome

Codeception scenario tests are called Cepts.

4. Write Basic Test

It's now time to write your first test. Edit the file we've just created tests/acceptance/WelcomeCept.php

  $I = new AcceptanceTester($scenario);
  $I->wantTo('ensure that frontpage works');

It will check that your frontpage contains the word Home in it.

5. Configure Acceptance Tests

Please make sure your local dev serveris running.  Put application URL into:  tests/acceptance.suite.yml 

class_name: AcceptanceTester
        - PhpBrowser:
            url: {YOUR APP'S URL}
        - \Helper\Acceptance

6. Run!

Codeception are executed with 'run' command

codecept run

This will execute our Welcome test with PhpBrowser. It's PHP script that can check HTML page contents, click links, fill forms, and submit POST and GET requests. For more complex tests that require a browser use Selenium with WebDriver module.

If you did everything right and your app has "Home" text on frontpage you will see this in output
Acceptance Tests (1) -------------------------------
✓ WelcomeCept: Ensure that frontpage works

Functional Tests -----------------------------------
Unit Tests -----------------------------------------

Time: 1 second, Memory: 21.00Mb
OK (1 test, 1 assertions)

Follow the Acceptance Testing chapter to learn how to test your web application by clicking links, filling forms, as your regular users do.