しごとのはなし

web関連の仕事の話をメモ的に。

codeceptionことはじめ、その2

で、QuickStartは終わったので、もう少し実用的な事を、と思うんだけど、とりあえず本日はここまでね。この先調査が進んだらまた書くってことで。

 

 

で、今のところ以下をやっておきたい、と思っている。

  • bootstrapでのテスト環境構築の自動化
  • カスタムアサートの作成

とりあえずテストの範囲もまだまだ小さいので、テスト環境構築の自動化は後にしようと思う。

 

 

で、$I->seeNoEvil();とかカスタムアサートを書きたい訳ですよ。

そもそもの混乱は以下に書いてある事と(v1.6.3ベースの)実際の挙動がちょっと違う、所から始まる。

http://codeception.com/docs/03-ModulesAndHelpers

 

Codeception doesn't restrict you to only the modules from the main repository. No doubt your project might need your own actions added to the test suite. By running the bootstrap command, Codeception generates three dummy modules for you, one for each of the newly created suites. These custom modules are called 'Helpers', and they can be found in the tests/helperspath.

 tests/helpersってないじゃん!!

 tests/_helpersじゃん!!

ぐらいで終われば良かったんだけど、そうは問屋が卸さなかった。

とりあえず、tests/_helpers/WebHelper.php

 

 

<?php
function seeNoEvil() { $this->assertTrue(true); } ?>

 

って書いて、Cept.phpの方に

 

 

<?php
$I = new WebGuy($scenario); :
$I->seeNoEvil();
?>

とか書くじゃないですか、そうすると

$ php codecept.phar run acceptance

 

でテストを走らせると

Suite acceptance started
Trying to see no evil (WelcomeCept.php) - Error
Time: 10 seconds, Memory: 13.75Mb There was 1 error: --------- 1) Couldn't see no evil in WelcomeCept.php RuntimeException: Call to undefined method WebGuy::seeNoEvil

 っておこられちゃう。

ここでオイラは2-3時間ぐらいかなりの泥沼に入るんだけど、結論としては、

$ php codecept.phar build

 で、解決。bootstrapで出来たWebGuiさんはSelenium用じゃなくてPhpbrowser向けだし、いずれかのタイミングで必要だった、という事みたいです。

 

以上、 今日はここまで。次回はseeNoEvilの中身を書きたいと思うよ。