I love iPhone, Android, Cocos2d-x
CakePHP1.2 SimpleTest の小技
CakePHP で SimpleTest を使うときにちょっとした小技の紹介です。
<?php
class UsersControllerTestCase extends CakeTestCase {
function startCase() {
echo '<h1>Starting Test Case</h1>';
}
function endCase() {
echo '<h1>Ending Test Case</h1>';
}
function startTest($method) {
echo '<h3>Starting method '.$method.'</h3>';
}
function endTest($method) {
echo '<hr/>';
}
function testIndex() {
$result = $this->testAction('/users/index');
debug($result);
}
}
?>
このテストケースを実行すると実行時に startCase が実行され、全てのテストケースが終了したときには endCase が実行されます。また、各テストが実行される時には startTest が実行され $method には テストのメソッド名が入ります。各テスト終了時には endTest が実行されます。
グループ化などでテストの数が多くなってくるとどのテストが実行されエラーになったかなど分かりやすくなります。
関連する投稿
コメントをどうぞ
Additional comments powered by BackType