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

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

  Nice~ 成功跑通~
  后,用phpunit.xml定義測試套,跑起來更便捷~
  老是敲那么一長串的命令也挺麻煩的,要是能像make一樣只要敲一個make搞定好了 —— phpunit剛好提供了一個phpunit.xml讓我們能定義常用的測試套之類的選項。
  詳細的介紹在官方文檔中已經(jīng)很詳細了,我這里不?嗦了。只秀個我認為較為簡潔有效的配置:
<?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變得非常簡單了,一個phpunit搞定了:

  Well done. 收工~

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