您的位置:軟件測(cè)試 > 開(kāi)源軟件測(cè)試 > 開(kāi)源功能測(cè)試工具 > Selenium
使用PHPUnit+Selenium進(jìn)行自動(dòng)化測(cè)試
作者:網(wǎng)絡(luò)轉(zhuǎn)載 發(fā)布時(shí)間:[ 2016/3/28 16:51:18 ] 推薦標(biāo)簽:自動(dòng)化測(cè)試 功能測(cè)試

  此外,其中create_browser是放在bootstrap.php中的一個(gè)輔助函數(shù):
  use FacebookWebDriverRemoteDesiredCapabilities;
  use FacebookWebDriverRemoteRemoteWebDriver;
  /**
  * @return RemoteWebDriver
  */
  function create_browser(){
  return RemoteWebDriver::create('http://localhost:4444/wd/hub',
  DesiredCapabilities::chrome(),
  5000);
  }
  第六步,跑一下測(cè)試用例試試
  phpunit --bootstrap tests/bootstrap.php tests/sample/BaiduTest.php

  Nice~ 成功跑通~
  后,用phpunit.xml定義測(cè)試套,跑起來(lái)更便捷~
  老是敲那么一長(zhǎng)串的命令也挺麻煩的,要是能像make一樣只要敲一個(gè)make搞定好了 —— phpunit剛好提供了一個(gè)phpunit.xml讓我們能定義常用的測(cè)試套之類的選項(xiàng)。
  詳細(xì)的介紹在官方文檔中已經(jīng)很詳細(xì)了,我這里不?嗦了。只秀個(gè)我認(rèn)為較為簡(jiǎn)潔有效的配置:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
backupGlobals               = "false"
backupStaticAttributes      = "false"
colors                      = "true"
convertErrorsToExceptions   = "true"
convertNoticesToExceptions  = "true"
convertWarningsToExceptions = "true"
processIsolation            = "false"
stopOnFailure               = "false"
syntaxCheck                 = "false"
bootstrap                   = "tests/bootstrap.php" >
<testsuites>
<testsuite>
<directory>tests/sample</directory>
</testsuite>
<!-- ... -->
</testsuites>
</phpunit>
  把上述內(nèi)容寫入phpunit.xml中后,跑phpunit變得非常簡(jiǎn)單了,一個(gè)phpunit搞定了:

  Well done. 收工~

上一頁(yè)12下一頁(yè)
軟件測(cè)試工具 | 聯(lián)系我們 | 投訴建議 | 誠(chéng)聘英才 | 申請(qǐng)使用列表 | 網(wǎng)站地圖
滬ICP備07036474 2003-2017 版權(quán)所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd