Codeception LogoCodeception

Modern PHP testing for everyone.

Acceptance Testing

Selenium WebDriver, PhpBrowser. Data cleanup. Continuous Integration. Remote CodeCoverage.

Functional Testing

Symfony2, Laravel, Yii, Phalcon, Zend Framework, Kohana, Databases, REST, SOAP, CodeCoverage.

API Testing

REST, SOAP, XML-RPC via PHPBrowser or PHP Frameworks.

...and unit testing powered by PHPUnit
Quick Start →

Write and execute a test for an existing app in less then 5 mins! No additional tools required. 

Codeception was started in November 2011, and released the first stable version 1.0 in January 2012. Based on Symfony2 Components, PHPUnit. Codeception is a mature and stable project, well-tested and documented. It's open-source and MIT licensed.

Join #codeception on FreeNode IRC.


  • Selenium WebDriver integration
  • Elements matched by name, CSS, XPath
  • Symfony2, Laravel4, Yii, Phalcon, Zend Framework integration
  • PageObjects and StepObjects included
  • BDD-style readable tests
  • Powered by PHPUnit
  • API testing: REST,SOAP,XML-RPC
  • Facebook API testing
  • Data Cleanup
  • HTML, XML, TAP, JSON reports
  • CodeCoverage and Remote CodeCoverage
  • Parallel Execution

Questions you wanted to ask


Do I really need this?

If you develop complex web applications with forms, links, and many pages (or maybe APIs), and you want to check all forms and links in minutes, you need to use a testing framework.


Why should I use this instead of PHPUnit?

Being the most popular unit testing framework PHPUnit has very limited features for functional testing with Selenium or other backends. Codeception is PHPUnit on steroids. Everything you need for testing is built-in and works just out of the box. No more pain in configuring Selenium, data cleanup, writing XPaths, and fixtures.


It looks just like Behat

Unlike Behat, Codeception tests are written in PHP. Thus, they are more flexible and easy in writing. Also you can use variables and operators, CSS and XPath locators in your tests. These features allow you to build a solid test automation platform for testing your web application. Codeception tests are simple and readable for your developers, managers, and QA team.


We are planning to use Selenium IDE. Why Codeception?

Codeception works great with Selenium. But with Codeception you can write your tests in PHP. The main reason is: Selenium IDE tests are tightly bound to XPath locators. If you ever change anything in layout tests will fall. Codeception locators are more stable. You can use names, labels, button names and CSS to match elements on page. It's much easier to support the Codeception test then Selenium's one. Selenium just can't clean data between tests, can't check database values, or generate code coverage reports.


Is Codeception a tool for testing legacy projects?

Sure you can use Codeception for black-box testing of your legacy application. But in the same manner you can start testing modern web application as well. With modules that integrates with all popular PHP frameworks you can start writing functional tests in seconds. Unit tests? Write them as you do in PHPUnit with some enhancement. Codeception keeps your tests in one place, makes them structured and readable.



Db PhpBrowser

Acceptance Test

$I = new AcceptanceTester($scenario);
$I->wantTo('create wiki page');
$I->see('New Page');
$I->fillField('title', 'Hobbit');
$I->fillField('body', 'By Peter Jackson');
$I->see('page created'); // notice generated
$I->see('Hobbit','h1'); // head of page of is our title
$I->seeInDatabase('pages', array('title' => 'Hobbit'));

This test can be executed inside Mozilla Firefox using Selenium Webdriver, or any browser. You can also execute this test without any browser by using a PHP browser emulator based on CURL.

Read more about Acceptance Tests →

This test can be also executed as a functional test in one of the popular PHP frameworks. Codeception has modules that support Symfony2, Zend Framework and Kohana.

Read more about Functional Tests →

PhpBrowser REST

API Test

$I = new ApiTester($scenario);
$I->wantTo('create a new user by API');
$I->sendPOST('/users', array('name' => 'davert' ));
$I->seeResponseContainsJson(array('result' => 'ok'));

This test can be executed inside PhpBrowser or as a functional test of one of the most popular PHP frameworks.

Read more about API Tests →

Unit Db

Unit Test

use \Codeception\Util\Stub;
class UserTest extends \Codeception\TestCase\Test
    public function testUserSave() {
        $user = Stub::make('User');
        $this->assertEquals('davert', $user->getName());
        $this->tester->seeInDatabase('users', array('name' => 'davert'));

PHPUnit test format with some useful helpers. In this test we check that value was saved to database with one simple command 'seeInDatabase'.

Read more about Unit Tests →


A side-project of Codeception for unit testing any PHP code. AspectMock most powerful mocking framework that can stub and mock practically anything. Even static methods, can be tested now. Use it for legacy or untestable code.

// mocking static method calls
$this->assertEquals('users', User::tableName());
test::double('User', ['tableName' => 'fake_users']);
$this->assertEquals('fake_users', User::tableName());

// mocking class method calls
test::double('User', ['getEmail' => '']);
$user = new User;
$this->assertEquals('', $user->getEmail());
Install AspectMock →