微型单元测试框架:Testify.php

jopen 10年前

Testify.php是一个微型的单元测试框架,非常人贩PHP5.3+。它力求高雅,而不是功能膨胀。测试你的代码不再是件苦差事 - 它将变得有乐趣。

include "testify/testify.class.php";  include "MyCalc.php";    $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(-5);   $tf->assertEqual($calc->result(),9);  });    $tf->test("Testing the mul() method", function($tf){   $calc = $tf->data->calc;     $calc->mul(1.5);   $tf->assertEqual($calc->result(),15);     $calc->mul(-1);   $tf->assertEqual($calc->result(),-15);  });    $tf->run();

项目主页:http://www.open-open.com/lib/view/home/1409814289322