微型單元測試框架: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();</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!