2008-02-27 EthnaでSimpleTest(1)
EthnaでSimpleTest(1)
まずはSimpleTestを使うための準備
etc/(app-id)-ini.phpのdebugフラグをtrueにする
'debug' => true,
どんなんができるんか確認。
file generated [/・・・/skel/skel.action_test.php -> /・・・/app/action/IndexTest.php]
action test(s) successfully created [/・・・/app/action/IndexTest.php]
ちょっと色々調べても「SimpleTestのドキュメントを読んで」とかしか書いてないねんけど。。。
でも、まぁ、やってみて気がついたこととかをメモとして。。。
(app_id)_Form_Index_TestCaseがアクションフォーム用のテストクラス、
(app_id)_Action_Index_TestCaseのアクション用のテストクラスらしい。
今回のテスト対象のindex.phpはアクションしか使ってないので
まずは(app_id)_Action_Index_TestCaseから使ってみますか!
/**
* @access private
*/
var $action_name = 'index';
/**
*
* @access public
*/
function setUp()
{
$this->createActionForm(); // アクションフォームの作成
$this->createActionClass(); // アクションクラスの作成
$this->session->start(); // セッションの開始
}
/**
* テストの後始末
*
* @access public
*/
function tearDown()
{
$this->session->destroy(); // セッションの破棄
}
/**
*
* @access public
*/
/*
function test_actionSample()
{
// フォームの設定
$forward_name = $this->ac->authenticate();
$this->assertNull($forward_name);
$forward_name = $this->ac->prepare();
$this->assertNull($forward_name);
$forward_name = $this->ac->perform();
$this->assertEqual($forward_name, 'index');
}
*/
この中身自体はSimpleTestの実装に乗っ取っているみたいで
setup()がテスト前処理、tearDown()がテスト後処理の関数となってるみたい。
で、test_actionSample()としてコメントアウトされてるところが
function test_actionIndex(){
$this->assertTrue(true);
}
trueで帰って来てんで!って感じで1passになってるんで、出だしは好調やな。。。
以下、OKの画面を参考までに。
んで、action自体は前処理部分の
$this->createActionForm(); // アクションフォームの作成
で作成されているみたいなので、
とりあえず、actionが作成されているかどうかはスケルトンで実装されている
$forward_name = $this->ac->perform();
$this->assertEqual($forward_name, 'index');
で確認できるみたいや。
これも実装したら、unittest.phpでpassできていることが確認できたから
あとは個別の確認をどないしていくか、また見て考えんといかん。
- 17 http://www.google.co.jp/search?hl=ja&client=firefox-a&rls=org.mozilla:ja:official&q=ethna+session+destroy+start&btnG=検索&lr=lang_ja
- 10 http://www.google.co.jp/search?q=ethna+simpletest&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 10 http://www.google.co.jp/url?sa=t&rct=j&q=ethna simpletest&source=web&cd=3&ved=0CCgQFjAC&url=http://d.hatena.ne.jp/fuminimax/20080227/1204469976&ei=sm7ETtOlMYyamQWclP3zCg&usg=AFQjCNEhpXYe5XQWseSl44v11GwiZ3Ye3w
- 9 http://www.google.co.jp/search?q=simpletest&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox
- 9 http://www.google.co.jp/url?sa=t&rct=j&q=ethna+simpletest&source=web&cd=1&ved=0CCUQFjAA&url=http://d.hatena.ne.jp/fuminimax/20080227/1204469976&ei=ZHI0T_6rCqP2mAXiysGEAg&usg=AFQjCNEhpXYe5XQWseSl44v11GwiZ3Ye3w
- 8 http://www.google.co.jp/search?q=simpletest+ethna&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 5 http://www.google.co.jp/search?hl=ja&q=Ethna+simpletest&btnG=Google+検索&lr=
- 5 http://www.google.co.jp/search?hl=ja&source=hp&q=ethna+simpletest&btnG=Google+検索&lr=&aq=0&oq=ethna+simp
- 5 http://www.google.co.jp/search?q=simpleTest+セッション&lr=lang_ja&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:ja:official&client=firefox-a
- 4 http://www.google.co.jp/search?client=firefox-a&rls=org.mozilla:ja:official&channel=s&hl=ja&q=simpleTest&lr=lang_ja&btnG=Google+検索
