Created
July 30, 2012 10:31
-
-
Save 77web/3206061 to your computer and use it in GitHub Desktop.
機能テストの書き方について。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// modules/foo/actions/actions.class.php | |
class fooActions extends sfActions | |
{ | |
public function executeBar(sfWebRequest $request) | |
{ | |
//何かの計算や条件判定 | |
$this->showNameInTitle = true; | |
$this->name = 'my name'; | |
} | |
} | |
?> | |
// modules/foo/templates/barSuccess.php | |
<h2><?php echo $showNameInTitle ? __('some title') : __('some title for %name%', array('%name%' => $name)); ?></h2> | |
経緯はこんな感じ。 | |
前提: | |
上記のようにアクション側で計算した何かのフラグを元にテンプレート側で分岐させて所定の文言を表示している。 | |
仕様変更1: | |
デザインの都合でHTMLタグがh2からh3に変わった。 | |
変更を担当した人が変更をテストに反映しないままマージされた。 | |
仕様変更2-A: | |
アクション側で値の計算方法が変わった。 | |
フラグの算出方法を変更しても、正しくsome titleとsome title for my nameが出力されているかテストしようとしたら、h2タグが存在しないという理由でテスト失敗。 | |
仕様変更2-B: | |
デザインの都合で文言がsome titleでなくnice titleに変わった。 | |
テンプレート内の文言変更によってsome titleでなくnice titleが出力されているかテストしようとしたら、h2タグが存在しないという理由でテスト失敗。 | |
1→2-Aや1→2-Bのような経緯を辿る時に1でテストを変更してくれなかったばかりに余計な手間がかかったので何とかしたい。 | |
ただ、機能テストのファイル数が多い&分散しているので、ちょっとしたタグを変更しただけの時(1の段階)に膨大な機能テストの中で該当するテストを全部探して修正するのまで要求するのは酷すぎ? | |
仕様変更1の前に該当する機能テストは削除して、2-A,2-Bはその都度新しい機能テストを作ってテストするのがベスト? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment