marcofiset / Testify.php

A micro unit testing framework
http://marco-fiset.github.com/Testify.php/
129 stars 27 forks source link

Testify - a micro unit testing framework

Testify is a micro unit testing framework for PHP 5.3+. It strives for elegance instead of feature bloat. Testing your code is no longer a chore - it's fun again.

Requirements

Usage

Here is an example for a test suite with two test cases:

require 'vendor/autoload.php';

use Math\MyCalc;
use Testify\Testify;

$tf = new Testify("MyCalc Test Suite");

$tf->beforeEach(function($tf) {
    $tf->data->calc = new MyCalc(10);
});

$tf->test("Testing the add() method", function($tf) {
    $calc = $tf->data->calc;

    $calc->add(4);
    $tf->assert($calc->result() == 14);

    $calc->add(-6);
    $tf->assertEquals($calc->result(), 8);
});

$tf->test("Testing the mul() method", function($tf) {
    $calc = $tf->data->calc;

    $calc->mul(1.5);
    $tf->assertEquals($calc->result(), 12);

    $calc->mul(-1);
    $tf->assertEquals($calc->result(), -12);
});

$tf();

Documentation