Install via Composer
composer require "codeception/codeception" --dev

2. Setup


php vendor/bin/codecept bootstrap

This creates configuration file codeception.yml and tests directory and default test suites.

codeception bootstrap

3. Create Test

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

php vendor/bin/codecept generate:cest Acceptance First

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}

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 if your frontpage contains the word Home.

6. Run!

Tests are executed with 'run' command

php vendor/bin/codecept run --steps

This will execute our test with PhpBrowser. It's PHP script that can check HTML page contents, click links, fill forms, and submit POST and GET requests. For tests that require a real browser (e.g. JavaScript) use the WebDriver module.

Simplified Setup

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

Acceptance Testing (only)

php vendor/bin/codecept init Acceptance
Acceptance Testing Guide »
codeception acceptance

REST API Testing (only)

php vendor/bin/codecept init Api
REST API Testing Guide »
codeception api

Unit Testing (only)

php vendor/bin/codecept init Unit
Unit Testing Guide »
codeception unit