当前位置: 软件>php软件
PHP 单元测试框架 Testify
本文导语: Testify(Testify.php) 是个极小的 PHP 5.3+ 单元测试框架。 代码示例: require 'vendor/autoload.php'; use MathMyCalc; use TestifyTestify;$tf = new Testify("MyCalc Test Suite");$tf->beforeEach(function($tf) { $tf->data->calc = new MyCalc(10);});$tf->test("Testing ...
Testify(Testify.php) 是个极小的 PHP 5.3+ 单元测试框架。
代码示例:
require 'vendor/autoload.php';
use MathMyCalc;
use TestifyTestify;$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();