Loading…
Transcript

Test automatici in PHP

Testo col browser

5 minuti dopo

sei mesi dopo

manca di ripetibilità

richiede tempo

non è completa

Automazione

Testo con

PHPUnit

arrange

act

assert

public function testTypingViaTheKeyboard()

{

$this->url('html/test_type_page1.html');

$usernameInput = $this->byName('username');

$usernameInput->value('TestUser');

$passwordInput = $this->byName('password');

$passwordInput->value('testUserPassword');

$this->clickOnElement('submitButton');

$h2 = $this->byCssSelector('h2');

$this->assertRegExp('/Welcome, TestUser!/',

$h2->text());

}

Design

class FormIscrizione

{

public function __construct() {

$this->database = new PDO("mysql:host=localhost;dbname=veicoli");

$this->erroriValidazione = file_get_contents("messages.txt");

$this->layout = Layout::getInstance();

}

}

Testo prima di scrivere il codice

TDD

class ArrayTest extends PHPUnit_Framework_TestCase

{

public function testArraysLengthCanBeCalculated()

{

$tagNames = array('div', 'p', 'a');

$count = count($tagNames);

$this->assertEquals(3, $count);

}

}

http://agileinaflash.blogspot.com/2009/02/red-green-refactor.html

qualità esterna

qualità interna

per lo sviluppatore

per il cliente

Giorgio Sironi

Software engineer

Allbus, DZone

@giorgiosironi

info@giorgiosironi.com