Slide 1

Slide 1 text

Codeception?> Modern PHP testing by Michael Bodnarchuk @davert

Slide 2

Slide 2 text

Why Codeception? • The simplest PHP testing tool ever. • Multiple frameworks integrations. • Powered by PHPUnit

Slide 3

Slide 3 text

THE SIMPLEST? Well, well, what did you say?

Slide 4

Slide 4 text

Aimed to be • Easy to read • Easy to write • Easy to debug

Slide 5

Slide 5 text

Judge by code $I = new WebGuy($scenario) $I->wantTo(‘sign up as a customer’); $I->click(‘Sign Up’); $I->fillField(‘name’,’Michael’); $I->fillField(‘password’,’qwerty’); $I->click(‘Submit’); $I->see(‘Hello, Michael!’);

Slide 6

Slide 6 text

HOW IS THAT EASY TO WRITE? It’s just a PHP code. Yep, it’s pretty clean, but…

Slide 7

Slide 7 text

Unleash the power of IDE

Slide 8

Slide 8 text

AND WHAT’S NEXT? So, writing test is nothing but point-and-click adventure…

Slide 9

Slide 9 text

Execute test Codeception PHP Testing Framework v1.1.0 Powered by PHPUnit 3.6.10 by Sebastian Bergmann. Suite acceptance started Trying to sign in as a customer (RegisterCept.php) Scenario: * I click “Sign Up" * I fill field “name",“Michael" * I fill field “password",“qwerty" * I click “Submit" * I see “Hello, Michael" OK Time: 2 seconds, Memory: 10.25Mb OK (1 test, 1 assertion) $ php codecept.phar run

Slide 10

Slide 10 text

Get more information Codeception PHP Testing Framework v1.1.0 Powered by PHPUnit 3.6.10 by Sebastian Bergmann. Suite acceptance started Trying to sign in as a customer (RegisterCept.php) Scenario: * I click “Sign Up" => Moved to page http://localhost/signup * I fill field “name",“Michael" * I fill field “password",“qwerty" * I click “Submit" => Moved to page http://localhost/user/michael * I see “Hello, Michael" OK Time: 2 seconds, Memory: 10.25Mb OK (1 test, 1 assertion) $ php codecept.phar run --debug

Slide 11

Slide 11 text

Even more? Debug! • Each broken step is highlighted. • The last response is saved when test fails. • Logs are written. • Page screenshots can be captured.

Slide 12

Slide 12 text

Yep, it’s really that simple

Slide 13

Slide 13 text

A bit of theory • We describe actions from user’s perspective. • We surf the site by clicking links, filling forms. • We expect to see predictable results on page.

Slide 14

Slide 14 text

DOES IT USE A BROWSER? But how is that executed, dude?

Slide 15

Slide 15 text

It’s up to you how to run the test • In a command line with PHPBrowser • Inside a real browser with Selenium • As a functional test of MVC framework

Slide 16

Slide 16 text

IS THAT EASY TO INSTALL TOO? Cool, I’m in!

Slide 17

Slide 17 text

Installation 1. Download ‘codecept.phar’ 2. Save it to PHP project. 3. Execute: php codecept.phar bootstrap php codecept.phar build

Slide 18

Slide 18 text

Give it a try! http://codeception.com