Quickstart Guide

Install via Composer

composer require "codeception/codeception" --dev

Execute it as ./vendor/bin/codecept


Execute it as php codecept.phar


Execute it as php codecept.phar

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

Execute it as codecept

2. Setup


codecept bootstrap

This creates configuration file codeception.yml and tests directory and default test suites. Acceptance, functional, unit test suites are created as well.

3. Create Test

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

codecept generate:cest acceptance First

Codeception scenario tests are called Cepts.

4. Configure Acceptance Tests

Please make sure your local development server is running.  Put application URL into:  tests/acceptance.suite.yml 

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

5. Write a Basic Test

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

class FirstCest 
    public function frontpageWorks(AcceptanceTester $I)

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

6. Run!

Tests are executed with 'run' command

codecept run --steps

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.

Simplified Setup

Use predefined installation templates for common use cases. Run them instead of bootstrap command.

Acceptance Testing (only)

codecept init acceptance
Acceptance Testing Guide »

REST API Testing (only)

codecept init api
REST API Testing Guide »

Unit Testing (only)

codecept init unit
Unit Testing Guide »