Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Codeceptionでテストをしよう

 Codeceptionでテストをしよう

PHPカンファレンス福岡2016 LT
http://php-tips.com/2016/05/21/phpconfuk2016-lt-codeception/

Takashi Nojima

May 21, 2016
Tweet

More Decks by Takashi Nojima

Other Decks in Technology

Transcript

  1. ‣ -BSBWFM -VNFO ‣ 1IBMDPO ‣ 4JMFY ‣ 4ZNGPOZ ‣

    :JJ ‣ ;FOE'SBNFXPSL ˞$BLF1)1͸ผ్Ϟδϡʔϧ ௥ՃͰରԠՄೳ ֤छϑϨʔϜϫʔΫΛඪ४αϙʔτ Codeception ͷ͍͍ͱ͜Ζ
  2. ςετίʔυ <?php ! $I = new AcceptanceTester($scenario); $I->wantTo('πΠολʔͰ #phpconfuk ΛݕࡧͰ͖Δ');

    ! $I->amOnPage('/'); $I->comment('ݕࡧϑΟʔϧυΛ։͍ͯೖྗ'); $I->click('ݕࡧ'); ! $I->waitForElementVisible('#search-query'); $I->fillField('#search-query', '#phpconfuk'); $I->click('.StreamsTopBar-searchButton'); $I->wait(3); ! $I->expect('ݕࡧϖʔδ͕։͍͍ͯΔ'); $I->seeCurrentUrlMatches('~^/search~'); $I->seeInTitle('#phpconfuk'); ! $I->expect('݁Ռʹ"1)1ΧϯϑΝϨϯε࠷ߴʂ"ΛؚΜͰ͍Δ'); $I->see('PHPΧϯϑΝϨϯε࠷ߴʂ', '#timeline');
  3. Cept <?php ! $I = new AcceptanceTester($scenario); $I->wantTo('log in as

    regular user'); ! $I->amOnPage('/login'); $I->fillField('Username','davert'); $I->fillField('Password','qwerty'); $I->click('Login'); ! $I->see('Hello, davert');
  4. Cest <?php ! class LoginCest { ! public function _before(AcceptanceTester

    $I) { } ! public function _after(AcceptanceTester $I) { } ! public function tryToTest(AcceptanceTester $I) { $I->wantTo('log in as regular user'); ! $I->amOnPage('/login'); $I->fillField('Username', 'davert'); $I->fillField('Password', 'qwerty'); $I->click('Login'); ! $I->see('Hello, davert'); } }
  5. Cept vs Cest $FTUͳΒ ‣ @CFGPSF @BGUFS ϝιουͰڞ௨ͷલॲཧʗ ޙॲཧ͕هड़Մೳ ‣

    ΞϊςʔγϣϯͰςετέʔεͷάϧʔϓԽ΍ґ ଘؔ܎Λهड़Մೳ