PHPUnit再評価。PHPUnit_Skeltonで雛形吐けるようになってるとは知りませんでした。

require_once("PHPUnit/Skeleton.php");
$ps = new PHPUnit_Skeleton("Book", "Book.php", true);
$ps->createTestClass();
$ps->writeTestClass();

吐かれるテストケースはこんな感じです。

/**
 * PHPUnit test case for Book
 * 
 * The method skeletons below need to be filled in with 
 * real data so that the tests will run correctly. Replace 
 * all EXPECTED_VAL and PARAM strings with real data. 
 * 
 * Created with PHPUnit_Skeleton on 2005-01-06
 */
require_once 'PHPUnit.php';
class BookTest extends PHPUnit_TestCase {

    var $Book;

    function BookTest($name)
    {
        $this->PHPUnit_TestCase($name);
    }

    function setUp()
    {
        require_once 'Book.php';
        $this->Book =& new Book(PARAM);
    }

    function tearDown()
    {
        unset($this->Book);
    }

    function testgetname()
    {
        $result   = $this->Book->getname(PARAM);
        $expected = EXPECTED_VAL;
        $this->assertEquals($expected, $result);
    }

    function testgetprice()
    {
        $result   = $this->Book->getprice(PARAM);
        $expected = EXPECTED_VAL;
        $this->assertEquals($expected, $result);
    }

    function testgetreleasedate()
    {
        $result   = $this->Book->getreleasedate(PARAM);
        $expected = EXPECTED_VAL;
        $this->assertEquals($expected, $result);
    }

}
// Running the test.
$suite  = new PHPUnit_TestSuite('BookTest');
$result = PHPUnit::run($suite);
echo $result->toString();

Antでこの辺もっと良い使い方になんないか考え中。

Comments


Option