Codeceptionでテストをしよう

 Codeceptionでテストをしよう

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

B63ed943582d5b36a78f3be3c4d659e2?s=128

Takashi Nojima

May 21, 2016
Tweet

Transcript

  1. Codeception! Ͱςετ͠Α͏ .BZ 1)1ΧϯϑΝϨϯε෱Ԭ

  2. About Me ໊લɿ໺ౡོʢͷ͡·͔ͨ͠ʣ ॴଐɿΠϥεςΟοΫίϯαϧλϯπגࣜձࣾ
 w CMPHIUUQQIQUJQTDPN w 5XJUUFS!OPKJNBHF

  3. ࿩͢͜ͱ w $PEFDFQUJPOͷ֓ཁ w σϞ w $FQUWT$FTU w ͓קΊϞδϡʔϧ

  4. Codeception ͱ͸

  5. Codeception ͱ͸ wड͚ೖΕςετ "DDFQUBODF5FTU  wػೳςετ 'VODUJPOBM5FTU  w୯ମςετ 6OJU5FTU

     Λ·ͱΊͯॲཧͰ͖ΔςεςΟϯάϑϨʔϜϫʔΫ
  6. Codeception ͱ͸ w ެࣜαΠτ
 IUUQDPEFDFQUJPODPN w ೔ຊޠυΩϡϝϯτ
 IUUQQJDDBHMJBOJHJUIVCJP$PEFDFQUJPOEPDTKB@+1

  7. Codeception ͷ͍͍ͱ͜Ζ 8FC%SJWFSʹΑΔ+BWB4DSJQUͷڍಈΛؚΊͨςετΛ 1)1Ͱॻ͚Δ ‣ ςετࣦഊ࣌ʹ͸ɺ)5.-΍εΫϦʔϯγϣοτΛ࢒ͯ͘͠ΕΔ ‣ 8FC%SJWFSʹ͸4FMFOJVNͷଞɺ1IBOUPN+4 8FC,JUϕʔεͷϔο υϨεϒϥ΢β

    ΋ར༻Մೳ
  8. ‣ -BSBWFM -VNFO ‣ 1IBMDPO ‣ 4JMFY ‣ 4ZNGPOZ ‣

    :JJ ‣ ;FOE'SBNFXPSL ˞$BLF1)1͸ผ్Ϟδϡʔϧ ௥ՃͰରԠՄೳ ֤छϑϨʔϜϫʔΫΛඪ४αϙʔτ Codeception ͷ͍͍ͱ͜Ζ
  9. Codeception ͷ͍͍ͱ͜Ζ ‣ 3&45"1*ͷςετ༻Ϟδϡʔϧ͕͋Δ ‣ +40/Ͱ஋Λฦ͢"1*ͷςετ͕؆୯ʹॻ͚Δ

  10. ςετ Λॻ͍ͯΈΔ

  11. ͜Μͳͷ w πΠολʔͰʮQIQDPOGVLʯΛݕࡧ w ݕࡧ݁Ռʹʮ1)1ΧϯϑΝϨϯε࠷ߴʂʯ͕ ؚ·Ε͍ͯΕ͹0,

  12. ςετίʔυ <?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');
  13. σϞ

  14. Cept vs Cest

  15. 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');
  16. 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'); } }
  17. Cept vs Cest $FTUͳΒ ‣ @CFGPSF @BGUFS ϝιουͰڞ௨ͷલॲཧʗ ޙॲཧ͕هड़Մೳ ‣

    ΞϊςʔγϣϯͰςετέʔεͷάϧʔϓԽ΍ґ ଘؔ܎Λهड़Մೳ
  18. ͓קΊϞδϡʔϧ

  19. ͓קΊϞδϡʔϧ w TJUFQIBOUPNBO w KBLPDIQIBOUPNKTJOTUBMMFS w DBQUCBSJUPOFNBJMDBUDIFSDPEFDFQUJPONPEVMF w NBJMDBUDIFSμϛʔ4.51αʔόΛ্ཱͪ͛ΕΔHFN

  20. ϚϧνόΠτ΁ͷରԠ ಺෦ͰTVCTUS౳ͷϚϧνόΠτະରԠͷؔ਺Λ࢖ ༻͍ͯ͠Δ ‣ ςετͷϝιου໊΍ϝοηʔδʹϚϧνόΠ τจࣈΛ࢖༻ͨ͠৔߹͸දࣔ΍ಈ࡞่͕ΕΔ

  21. IDEͷରԠ w /FU#FBOT͔ΒରԠ w 1)14UPSNϓϥάΠϯͰରԠ w IUUQTHJUIVCDPNUJHFSTFPDPEFDFQUJPOQIQTUPSN DPNNBOEMJOFUPPM

  22. ͝ਗ਼ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠