•
    @shin1x1 / http://iplus.im/shin1x1

• ×
• Shin x blog http://www.1x1.jp/blog/
• PHP / Goolge+ /      / MotoGP
•


•
1. FizzBuzz
2.
3.
4. Selenium IDE
5. SimpleTest
6.
•   1       100



•
    3                       Fizz
    5             Buzz
    3   5                FizzBuzz
<?php
class FizzbuzzController extends AppController {
  public $uses = array();

    public function index() {
      for ($i = 1 ; $i <= 100 ; $i++) {
        if ($i % 3 === 0 && $i % 5 === 0) {
          echo 'FizzBuzz<br />';
        } else if ($i % 3 === 0) {
          echo 'Fizz<br />';
        } else if ($i % 5 === 0) {
          echo 'Buzz<br />';
        } else {
          echo $i.'<br />';
        }
      }
      exit;
    }
}
• Selenium IDE
• SimpleTest 1.0.1
• CakePHP 1.3.10
•
  https://github.com/shin1x1/CakePHP-FizzBuzz
• Web
• Firefox
•
•
• ATND
•           /      /

• Twitter       tweet
• PHP
• PHPUnit
• CakePHP
• CakePHP   PHPUnit
• SimpleTest
•
•
•
•   ok   ng
$ret = Calc::double(3);




• Calc::double()
•
$ret = Calc::double(3);
$this->assertIdentical(6, $ret);


• Calc::double(3)      6

• 6 === $ret
•            ok              ng
assertIdentical($a, $b);    $a === $b

 assertEqual($a, $b);       $a == $b

   assertTrue($b);         (boolean)$b

   assertFalse($b);        !(boolean)$b

   assertNull($b);          !isset($b)
assertBodyText

assertTextPresent

   assertValue      value

 assertLocation             URL

  assertCookie      Cookie
assertAlert assertAlertNotPresent assertAlertPresent assertAllButtons assertAllFields assertAllLinks assertAllWindowIds
assertAllWindowNames assertAllWindowTitles assertAttribute assertAttributeFromAllWindows assertBodyText
assertChecked assertConfirmation assertConfirmationNotPresent assertConfirmationPresent assertCookie
assertCookieByName assertCookieNotPresent assertCookiePresent assertCursorPosition assertEditable
assertElementHeight assertElementIndex assertElementNotPresent assertElementPositionLeft assertElementPositionTop
assertElementPresent assertElementWidth assertEval assertExpression assertHtmlSource assertLocation
assertMouseSpeed assertNotAlert assertNotAllButtons assertNotAllFields assertNotAllLinks assertNotAllWindowIds
assertNotAllWindowNames assertNotAllWindowTitles assertNotAttribute assertNotAttributeFromAllWindows
assertNotBodyText assertNotChecked assertNotConfirmation assertNotCookie assertNotCookieByName
assertNotCursorPosition assertNotEditable assertNotElementHeight assertNotElementIndex
assertNotElementPositionLeft assertNotElementPositionTop assertNotElementWidth assertNotEval assertNotExpression
assertNotHtmlSource assertNotLocation assertNotMouseSpeed assertNotOrdered assertNotPrompt
assertNotSelectOptions assertNotSelected assertNotSelectedId assertNotSelectedIds assertNotSelectedIndex
assertNotSelectedIndexes assertNotSelectedLabel assertNotSelectedLabels assertNotSelectedValue
assertNotSelectedValues assertNotSomethingSelected assertNotSpeed assertNotTable assertNotText assertNotTitle
assertNotValue assertNotVisible assertNotWhetherThisFrameMatchFrameExpression
assertNotWhetherThisWindowMatchWindowExpression assertNotXpathCount assertOrdered assertPrompt
assertPromptNotPresent assertPromptPresent assertSelectOptions assertSelectedId assertSelectedIds assertSelectedIndex
assertSelectedIndexes assertSelectedLabel assertSelectedLabels assertSelectedValue assertSelectedValues
assertSomethingSelected assertSpeed assertTable assertText assertTextNotPresent assertTextPresent assertTitle
assertValue assertVisible assertWhetherThisFrameMatchFrameExpression
assertWhetherThisWindowMatchWindowExpression assertXpathCount
assertAlert assertAlertNotPresent assertAlertPresent assertAllButtons assertAllFields assertAllLinks assertAllWindowIds assertAllWindowNames
assertAllWindowTitles assertAttribute assertAttributeFromAllWindows assertBodyText assertChecked assertConfirmation assertConfirmationNotPresent
assertConfirmationPresent assertCookie assertCookieByName assertCookieNotPresent assertCookiePresent assertCursorPosition assertEditable assertElementHeight
assertElementIndex assertElementNotPresent assertElementPositionLeft assertElementPositionTop assertElementPresent assertElementWidth assertEval
assertExpression assertHtmlSource assertLocation assertMouseSpeed assertNotAlert assertNotAllButtons assertNotAllFields assertNotAllLinks assertNotAllWindowIds
assertNotAllWindowNames assertNotAllWindowTitles assertNotAttribute assertNotAttributeFromAllWindows assertNotBodyText assertNotChecked
assertNotConfirmation assertNotCookie assertNotCookieByName assertNotCursorPosition assertNotEditable assertNotElementHeight assertNotElementIndex
assertNotElementPositionLeft assertNotElementPositionTop assertNotElementWidth assertNotEval assertNotExpression assertNotHtmlSource assertNotLocation
assertNotMouseSpeed assertNotOrdered assertNotPrompt assertNotSelectOptions assertNotSelected assertNotSelectedId assertNotSelectedIds
assertNotSelectedIndex assertNotSelectedIndexes assertNotSelectedLabel assertNotSelectedLabels assertNotSelectedValue assertNotSelectedValues
assertNotSomethingSelected assertNotSpeed assertNotTable assertNotText assertNotTitle assertNotValue assertNotVisible
assertNotWhetherThisFrameMatchFrameExpression assertNotWhetherThisWindowMatchWindowExpression assertNotXpathCount assertOrdered assertPrompt
assertPromptNotPresent assertPromptPresent assertSelectOptions assertSelectedId assertSelectedIds assertSelectedIndex assertSelectedIndexes assertSelectedLabel
assertSelectedLabels assertSelectedValue assertSelectedValues assertSomethingSelected assertSpeed assertTable assertText assertTextNotPresent assertTextPresent
assertTitle assertValue assertVisible assertWhetherThisFrameMatchFrameExpression assertWhetherThisWindowMatchWindowExpression assertXpathCount
verifyErrorOnNext verifyNotErrorOnNext verifyFailureOnNext verifyNotFailureOnNext verifySelected verifyNotSelected verifyAlert verifyNotAlert verifyAllButtons
verifyNotAllButtons verifyAllFields verifyNotAllFields verifyAllLinks verifyNotAllLinks verifyAllWindowIds verifyNotAllWindowIds verifyAllWindowNames
verifyNotAllWindowNames verifyAllWindowTitles verifyNotAllWindowTitles verifyAttribute verifyNotAttribute verifyAttributeFromAllWindows
verifyNotAttributeFromAllWindows verifyBodyText verifyNotBodyText verifyConfirmation verifyNotConfirmation verifyCookie verifyNotCookie verifyCookieByName
verifyNotCookieByName verifyCursorPosition verifyNotCursorPosition verifyElementHeight verifyNotElementHeight verifyElementIndex verifyNotElementIndex
verifyElementPositionLeft verifyNotElementPositionLeft verifyElementPositionTop verifyNotElementPositionTop verifyElementWidth verifyNotElementWidth verifyEval
verifyNotEval verifyExpression verifyNotExpression verifyHtmlSource verifyNotHtmlSource verifyLocation verifyNotLocation verifyMouseSpeed verifyNotMouseSpeed
verifyPrompt verifyNotPrompt verifySelectedId verifyNotSelectedId verifySelectedIds verifyNotSelectedIds verifySelectedIndex verifyNotSelectedIndex
verifySelectedIndexes verifyNotSelectedIndexes verifySelectedLabel verifyNotSelectedLabel verifySelectedLabels verifyNotSelectedLabels verifySelectedValue
verifyNotSelectedValue verifySelectedValues verifyNotSelectedValues verifySelectOptions verifyNotSelectOptions verifySpeed verifyNotSpeed verifyTable verifyNotTable
verifyText verifyNotText verifyTitle verifyNotTitle verifyValue verifyNotValue verifyWhetherThisFrameMatchFrameExpression
verifyNotWhetherThisFrameMatchFrameExpression verifyWhetherThisWindowMatchWindowExpression verifyNotWhetherThisWindowMatchWindowExpression
verifyXpathCount verifyNotXpathCount verifyAlertPresent verifyAlertNotPresent verifyChecked verifyNotChecked verifyConfirmationPresent
verifyConfirmationNotPresent verifyCookiePresent verifyCookieNotPresent verifyEditable verifyNotEditable verifyElementPresent verifyElementNotPresent
verifyOrdered verifyNotOrdered verifyPromptPresent verifyPromptNotPresent verifySomethingSelected verifyNotSomethingSelected verifyTextPresent
verifyTextNotPresent verifyVisible verifyNotVisible
•   OK = GREEN




•   NG = RED
1.

2.

3.

4.
• SimpleTest
  http://www.simpletest.org/



• Selenium IDE
  http://seleniumhq.org/projects/ide/


• CakePHP
  http://cakephp.org/
FizzBuzzではじめるテスト

FizzBuzzではじめるテスト

  • 2.
    @shin1x1 / http://iplus.im/shin1x1 • × • Shin x blog http://www.1x1.jp/blog/ • PHP / Goolge+ / / MotoGP
  • 4.
  • 5.
    1. FizzBuzz 2. 3. 4. SeleniumIDE 5. SimpleTest 6.
  • 7.
    1 100 • 3 Fizz 5 Buzz 3 5 FizzBuzz
  • 9.
    <?php class FizzbuzzController extendsAppController { public $uses = array(); public function index() { for ($i = 1 ; $i <= 100 ; $i++) { if ($i % 3 === 0 && $i % 5 === 0) { echo 'FizzBuzz<br />'; } else if ($i % 3 === 0) { echo 'Fizz<br />'; } else if ($i % 5 === 0) { echo 'Buzz<br />'; } else { echo $i.'<br />'; } } exit; } }
  • 11.
    • Selenium IDE •SimpleTest 1.0.1 • CakePHP 1.3.10 • https://github.com/shin1x1/CakePHP-FizzBuzz
  • 12.
  • 13.
    • ATND • / / • Twitter tweet
  • 14.
    • PHP • PHPUnit •CakePHP • CakePHP PHPUnit
  • 15.
  • 17.
  • 18.
    $ret = Calc::double(3); •Calc::double() •
  • 19.
    $ret = Calc::double(3); $this->assertIdentical(6,$ret); • Calc::double(3) 6 • 6 === $ret • ok ng
  • 20.
    assertIdentical($a, $b); $a === $b assertEqual($a, $b); $a == $b assertTrue($b); (boolean)$b assertFalse($b); !(boolean)$b assertNull($b); !isset($b)
  • 22.
    assertBodyText assertTextPresent assertValue value assertLocation URL assertCookie Cookie
  • 23.
    assertAlert assertAlertNotPresent assertAlertPresentassertAllButtons assertAllFields assertAllLinks assertAllWindowIds assertAllWindowNames assertAllWindowTitles assertAttribute assertAttributeFromAllWindows assertBodyText assertChecked assertConfirmation assertConfirmationNotPresent assertConfirmationPresent assertCookie assertCookieByName assertCookieNotPresent assertCookiePresent assertCursorPosition assertEditable assertElementHeight assertElementIndex assertElementNotPresent assertElementPositionLeft assertElementPositionTop assertElementPresent assertElementWidth assertEval assertExpression assertHtmlSource assertLocation assertMouseSpeed assertNotAlert assertNotAllButtons assertNotAllFields assertNotAllLinks assertNotAllWindowIds assertNotAllWindowNames assertNotAllWindowTitles assertNotAttribute assertNotAttributeFromAllWindows assertNotBodyText assertNotChecked assertNotConfirmation assertNotCookie assertNotCookieByName assertNotCursorPosition assertNotEditable assertNotElementHeight assertNotElementIndex assertNotElementPositionLeft assertNotElementPositionTop assertNotElementWidth assertNotEval assertNotExpression assertNotHtmlSource assertNotLocation assertNotMouseSpeed assertNotOrdered assertNotPrompt assertNotSelectOptions assertNotSelected assertNotSelectedId assertNotSelectedIds assertNotSelectedIndex assertNotSelectedIndexes assertNotSelectedLabel assertNotSelectedLabels assertNotSelectedValue assertNotSelectedValues assertNotSomethingSelected assertNotSpeed assertNotTable assertNotText assertNotTitle assertNotValue assertNotVisible assertNotWhetherThisFrameMatchFrameExpression assertNotWhetherThisWindowMatchWindowExpression assertNotXpathCount assertOrdered assertPrompt assertPromptNotPresent assertPromptPresent assertSelectOptions assertSelectedId assertSelectedIds assertSelectedIndex assertSelectedIndexes assertSelectedLabel assertSelectedLabels assertSelectedValue assertSelectedValues assertSomethingSelected assertSpeed assertTable assertText assertTextNotPresent assertTextPresent assertTitle assertValue assertVisible assertWhetherThisFrameMatchFrameExpression assertWhetherThisWindowMatchWindowExpression assertXpathCount
  • 24.
    assertAlert assertAlertNotPresent assertAlertPresentassertAllButtons assertAllFields assertAllLinks assertAllWindowIds assertAllWindowNames assertAllWindowTitles assertAttribute assertAttributeFromAllWindows assertBodyText assertChecked assertConfirmation assertConfirmationNotPresent assertConfirmationPresent assertCookie assertCookieByName assertCookieNotPresent assertCookiePresent assertCursorPosition assertEditable assertElementHeight assertElementIndex assertElementNotPresent assertElementPositionLeft assertElementPositionTop assertElementPresent assertElementWidth assertEval assertExpression assertHtmlSource assertLocation assertMouseSpeed assertNotAlert assertNotAllButtons assertNotAllFields assertNotAllLinks assertNotAllWindowIds assertNotAllWindowNames assertNotAllWindowTitles assertNotAttribute assertNotAttributeFromAllWindows assertNotBodyText assertNotChecked assertNotConfirmation assertNotCookie assertNotCookieByName assertNotCursorPosition assertNotEditable assertNotElementHeight assertNotElementIndex assertNotElementPositionLeft assertNotElementPositionTop assertNotElementWidth assertNotEval assertNotExpression assertNotHtmlSource assertNotLocation assertNotMouseSpeed assertNotOrdered assertNotPrompt assertNotSelectOptions assertNotSelected assertNotSelectedId assertNotSelectedIds assertNotSelectedIndex assertNotSelectedIndexes assertNotSelectedLabel assertNotSelectedLabels assertNotSelectedValue assertNotSelectedValues assertNotSomethingSelected assertNotSpeed assertNotTable assertNotText assertNotTitle assertNotValue assertNotVisible assertNotWhetherThisFrameMatchFrameExpression assertNotWhetherThisWindowMatchWindowExpression assertNotXpathCount assertOrdered assertPrompt assertPromptNotPresent assertPromptPresent assertSelectOptions assertSelectedId assertSelectedIds assertSelectedIndex assertSelectedIndexes assertSelectedLabel assertSelectedLabels assertSelectedValue assertSelectedValues assertSomethingSelected assertSpeed assertTable assertText assertTextNotPresent assertTextPresent assertTitle assertValue assertVisible assertWhetherThisFrameMatchFrameExpression assertWhetherThisWindowMatchWindowExpression assertXpathCount verifyErrorOnNext verifyNotErrorOnNext verifyFailureOnNext verifyNotFailureOnNext verifySelected verifyNotSelected verifyAlert verifyNotAlert verifyAllButtons verifyNotAllButtons verifyAllFields verifyNotAllFields verifyAllLinks verifyNotAllLinks verifyAllWindowIds verifyNotAllWindowIds verifyAllWindowNames verifyNotAllWindowNames verifyAllWindowTitles verifyNotAllWindowTitles verifyAttribute verifyNotAttribute verifyAttributeFromAllWindows verifyNotAttributeFromAllWindows verifyBodyText verifyNotBodyText verifyConfirmation verifyNotConfirmation verifyCookie verifyNotCookie verifyCookieByName verifyNotCookieByName verifyCursorPosition verifyNotCursorPosition verifyElementHeight verifyNotElementHeight verifyElementIndex verifyNotElementIndex verifyElementPositionLeft verifyNotElementPositionLeft verifyElementPositionTop verifyNotElementPositionTop verifyElementWidth verifyNotElementWidth verifyEval verifyNotEval verifyExpression verifyNotExpression verifyHtmlSource verifyNotHtmlSource verifyLocation verifyNotLocation verifyMouseSpeed verifyNotMouseSpeed verifyPrompt verifyNotPrompt verifySelectedId verifyNotSelectedId verifySelectedIds verifyNotSelectedIds verifySelectedIndex verifyNotSelectedIndex verifySelectedIndexes verifyNotSelectedIndexes verifySelectedLabel verifyNotSelectedLabel verifySelectedLabels verifyNotSelectedLabels verifySelectedValue verifyNotSelectedValue verifySelectedValues verifyNotSelectedValues verifySelectOptions verifyNotSelectOptions verifySpeed verifyNotSpeed verifyTable verifyNotTable verifyText verifyNotText verifyTitle verifyNotTitle verifyValue verifyNotValue verifyWhetherThisFrameMatchFrameExpression verifyNotWhetherThisFrameMatchFrameExpression verifyWhetherThisWindowMatchWindowExpression verifyNotWhetherThisWindowMatchWindowExpression verifyXpathCount verifyNotXpathCount verifyAlertPresent verifyAlertNotPresent verifyChecked verifyNotChecked verifyConfirmationPresent verifyConfirmationNotPresent verifyCookiePresent verifyCookieNotPresent verifyEditable verifyNotEditable verifyElementPresent verifyElementNotPresent verifyOrdered verifyNotOrdered verifyPromptPresent verifyPromptNotPresent verifySomethingSelected verifyNotSomethingSelected verifyTextPresent verifyTextNotPresent verifyVisible verifyNotVisible
  • 25.
    OK = GREEN • NG = RED
  • 30.
  • 31.
    • SimpleTest http://www.simpletest.org/ • Selenium IDE http://seleniumhq.org/projects/ide/ • CakePHP http://cakephp.org/