Created
January 10, 2012 10:01
-
-
Save arnested/1588277 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This file contains a PHP class "SeleneseTestSauceOnDemand". | |
* | |
* It is made for easy automation of running Selenese (Selenium IDE's HTML | |
* format) test cases on Saucelabs SauceOnDemand service. | |
* | |
* You should be able to excute all Selenese test cases in a directory without | |
* modifying this file either by: | |
* | |
* - defining the ___STSOD_... constants in a phpunit bootstrap file. | |
* - defining the ___STSOD_... constants in a phpunit.xml file. | |
* - have your automatic build system generate the above or preprocess a copy | |
* of this file. | |
*/ | |
require_once 'PHPUnit/Extensions/SeleniumTestCase/SauceOnDemandTestCase.php'; | |
/** | |
* // The following line makes the class 'SeleneseTestSauceOnDemand' run its tests | |
* // in parallel. PHP can read it even though it lives in a comment. | |
* // Read more at http://blog.fedecarg.com/2008/07/19/using-annotations-in-php/ | |
* | |
* @runTestsInParallel 10 | |
*/ | |
class ___SeleneseTestSauceOnDemand___ extends PHPUnit_Extensions_SeleniumTestCase_SauceOnDemandTestCase | |
{ | |
/** | |
* Set the directory containing your Selenium test cases | |
*/ | |
public static $seleneseDirectory = ___STSOD_SELENESE_DIRECTORY___; | |
/** | |
* Manipulate "browser name" to reflect project name and name of the test | |
* case. Saucelabs uses the browser name to desribe the test cases. | |
* | |
* Also set Saucelabs username and access key so we can configure this | |
* outside $HOME. | |
*/ | |
public function __construct($name = NULL, array $data = array(), $dataName = '', array $browser = array()) | |
{ | |
// setup browser, browserVersion and os | |
list( | |
$browser['browser'], | |
$browser['browserVersion'], | |
$browser['os'] | |
) = explode('|', ___STSOD_BROWSER___, 3); | |
// setup name of job | |
$browser['name'] = ___STSOD_PROJECT_NAME___ . ': ' . basename($name, '.html'); | |
// setup additional config | |
$browser['recordVideo'] = ___STSOD_RECORD_VIDEO___; | |
$browser['recordScreenshots'] = ___STSOD_RECORD_SCREENSHOTS___; | |
$browser['sauceAdvisor'] = ___STSOD_SAUCE_ADVISOR___; | |
$browser['maxDuration'] = ___STSOD_MAX_DURATION___; | |
$browser['idleTimeout'] = ___STSOD_IDLE_TIMEOUT___; | |
// setup Saucelabs username and access key | |
$browser['username'] = ___STSOD_USERNAME___; | |
$browser['accessKey'] = ___STSOD_ACCESSKEY___; | |
parent::__construct($name, $data, $dataName, $browser); | |
} | |
/** | |
* Specify which sites to run the tests against. | |
* | |
* This will override the setUp() in the selenese test case. | |
*/ | |
protected function setUp() | |
{ | |
$this->setBrowserUrl(___STSOD_SITE_URL___); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment