Codeception LogoCodeception

Modern PHP testing for everyone.


Acceptance Testing

Selenium2, PhpBrowser. Data cleanup. Continuous Integration. Remote CodeCoverage.


Functional Testing

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


Unit Testing

PHPUnit tests, with better stubs, and database interactions. Readable scenario-driven tests. CodeCoverage.

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, Mink. 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, 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 after each run
  • HTML, XML, TAP, JSON reports
  • CodeCoverage and Remote CodeCoverage

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.


No need for this. It looks just like Behat

Hold on! Even though it uses the same style in test descriptions and Mink as a driver, Codeception is completely different. Codeception tests are written in PHP they are written much faster, especially if you use an IDE. You can use variables and operators in your tests. You can use CSS and XPathselectors in your tests. These features allow you to build a solid test automation platform for testing your web application. Codeception tests are very readable for your developers, managers, and QA team.


We are planning to use Selenium. Why Codeception?

Codeception works great with Selenium. But with Codeception you can write your tests in PHP. The main reason is: Selenium 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.


Why do all tests starts with 'Guy'?

I'm not sexist in any form, but we call the test worker a Guy. Think of it as an imaginable person that describers his actions in PHP DSL. "I am new guy", he says. "I want to test your application", he says. "I click 'Log In', fill fields, and I see 'Hello' in page", he says. In our team we just thought it is more natural to write tests from a person's perspective, than just commands.



Db PhpBrowser

Acceptance Test

$I = new WebGuy($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 ApiGuy($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->codeGuy->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 →