微型单元测试框架:Testify.php
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();
本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!