testing php with codeception

13
Testing PHP with Codeception

Upload: john-paul-ada

Post on 13-Apr-2017

86 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Testing PHP with Codeception

Testing PHP with

Codeception

Page 2: Testing PHP with Codeception

Test Driven Developmenta Primer

Test before you code.

Tests should be easy to write.

If they’re not easy to write, it’s not the test. It’s the code.

Page 3: Testing PHP with Codeception

Test Driven Developmenta Primer

Unit test Integration test UI test

TYPES OF TESTS

Page 4: Testing PHP with Codeception

Codeception

Page 5: Testing PHP with Codeception

What is Codeception?

Codeception is a PHP testing framework.

Page 6: Testing PHP with Codeception

What is Codeception?

It has good support for PHP frameworks likeSymphony, Laravel, etc.

Page 7: Testing PHP with Codeception

#!/bin/sh # Install via composer

composer require "codeception/codeception" alias codecept='./vendor/bin/codecept'

Installation

Page 8: Testing PHP with Codeception

#!/bin/sh # Install via composer

codecept bootstrap --empty

Setup

Page 9: Testing PHP with Codeception

// Unit Test Example // ExampleTest.php

<?php public function testUserReturnsRightFullName() { $firstName = “John Paul”; $lastName = “Ada” $fullName = “John Paul Ada”; $user = new User(“John Paul”, “Ada”); $this->assertTrue($user->getFullName() == $fullName);

}

Unit tests

Page 10: Testing PHP with Codeception

// Acceptance Test Example // WelcomeCept.php

<?php $I = new AcceptanceTester($scenario); $I->wantTo(‘Ensure that home page works.’); $I->amOnPage(‘/‘); $I->see(‘Welcome’);

Acceptance tests

Page 11: Testing PHP with Codeception

#!/bin/sh # Running codeception

codecept run

Run on LOCAL Run on CI SERVER

Page 12: Testing PHP with Codeception

Output

Page 13: Testing PHP with Codeception

fin.