Codeception BDD style Unit tests

Nov 21, 2013, 8:09:25 PM

Recently davertMik had announced an addition to Codeception framework that allows BDD style unit test. Pretty nice like this

        $this->specify('post can be published', function() {
            $this->post->setTitle('Testing is Fun!');
            $this->post->setBody('Thats for sure');

Two new additional libraries introduced for this Specify and Verify

These libs are very easy to add into you project via Composer.


is a helper trait that allow to organize tests in "containers" for better readability like

$this->specify("i can change my name", function() {
   $this->user->name = 'jon';
   $this->assertEquals('jon', $this->user->name);

very interesing is DataProvider feature that will help to test a number of edge conditions

$this->specify("should calculate square numbers", function($number, $square) {
    $this->assertEquals($square, $number*$number);
}, ['examples' => [

see detailed docs


add 2 functions verify() and alias expect() and wrap all PHPUnit assertions in such way


see detailed docs

What is missing ?

As for me these libs are exactly what I wanted from Codeception. The only thing I still need is ability to generate steps report on passed test. As now I describe everything in human-readable format via Specify - I would like to be able to get "passed-tests-walk-through" as a report.

comments powered by Disqus
Kuzminov "iJackUA"
Web Team Lead
at MobiDev (Kharkiv, Ukraine)
Code in Ruby and Elixir, but still love PHP. Explore ES6 and Vue.js. Explore databases, use Ubuntu and MacOS, think about IT people and management


Skaffold tool that facilitates continuous development for Kubernetes-native applications. Continuously deploys to your local or remote Kubernetes cluster.

DoItLive is a tool for live presentations in the terminal. It reads a file of shell commands and replays the commands in a fake terminal session as you type random characters.