PHP simpletest のテストケース書きまくりなんだけど、テストケース自体を書くのがめんどくさくなってきた。
200件とか書いていると漏れもあるだろうし、時間もかかるし。
こんなかんじでテストケースかけねーかな。
いままで(全部配列で用意)
$testcase = array( array('name'=>'', 'result'=>false), array('name'=>'a', 'result'=>true), array('name'=>'kasuya', 'result'=>true), array('name'=>'1234567890', 'result'=>true), array('name'=>'12345678901', 'result'=>false), ); foreach ($testcase as $t) { $result = xxx::test_function( $t['name'] ); $this->assertEqual( $result, $t['result'] ); }; .......
これから(テストケースも自動生成)
$testcase = xxx::create_testcase('name=id:type=string:length=1-10');
foreach ($testcase as $t)
{
$result = xxx::test_function( $t['name'] );
$this->assertEqual( $result, $t['result'] );
}
........