Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php |
— | — | @@ -29,9 +29,9 @@ |
30 | 30 | require_once( dirname( dirname( __FILE__ ) )."/Maintenance.php" ); |
31 | 31 | require_once( 'PHPUnit/Framework.php' ); |
32 | 32 | require_once( 'PHPUnit/Extensions/SeleniumTestCase.php' ); |
| 33 | +require_once( 'PHPUnit/Util/Log/JUnit.php' ); |
33 | 34 | require_once( dirname( __FILE__ ) . "/selenium/SeleniumServerManager.php" ); |
34 | 35 | |
35 | | - |
36 | 36 | class SeleniumTester extends Maintenance { |
37 | 37 | protected $selenium; |
38 | 38 | protected $serverManager; |
— | — | @@ -51,6 +51,7 @@ |
52 | 52 | $this->addOption( 'verbose', 'Be noisier.' ); |
53 | 53 | $this->addOption( 'startserver', 'Start Selenium Server (on localhost) before the run.' ); |
54 | 54 | $this->addOption( 'stopserver', 'Stop Selenium Server (on localhost) after the run.' ); |
| 55 | + $this->addOption( 'jUnitLogFile', 'Log results in a specified JUnit log file.', false, true ); |
55 | 56 | $this->deleteOption( 'dbpass' ); |
56 | 57 | $this->deleteOption( 'dbuser' ); |
57 | 58 | $this->deleteOption( 'globals' ); |
— | — | @@ -111,9 +112,13 @@ |
112 | 113 | protected function runTests( $seleniumTestSuites = array() ) { |
113 | 114 | $result = new PHPUnit_Framework_TestResult; |
114 | 115 | $result->addListener( new SeleniumTestListener( $this->selenium->getLogger() ) ); |
| 116 | + if ( $this->selenium->getJUnitLogFile() ) { |
| 117 | + $jUnitListener = new PHPUnit_Util_Log_JUnit( $this->selenium->getJUnitLogFile(), true ); |
| 118 | + $result->addListener( $jUnitListener ); |
| 119 | + } |
115 | 120 | |
116 | 121 | foreach ( $seleniumTestSuites as $testSuiteName => $testSuiteFile ) { |
117 | | - require( $testSuiteFile ); |
| 122 | + require( $testSuiteFile ); |
118 | 123 | $suite = new $testSuiteName(); |
119 | 124 | $suite->addTests(); |
120 | 125 | |
— | — | @@ -124,6 +129,10 @@ |
125 | 130 | throw new MWException( $e->getMessage() ); |
126 | 131 | } |
127 | 132 | } |
| 133 | + |
| 134 | + if ( $this->selenium->getJUnitLogFile() ) { |
| 135 | + $jUnitListener->flush(); |
| 136 | + } |
128 | 137 | } |
129 | 138 | |
130 | 139 | public function execute() { |
— | — | @@ -169,6 +178,7 @@ |
170 | 179 | if ( !isset( $seleniumSettings['username'] ) ) $seleniumSettings['username'] = ''; |
171 | 180 | if ( !isset( $seleniumSettings['userPassword'] ) ) $seleniumSettings['userPassword'] = ''; |
172 | 181 | if ( !isset( $seleniumSettings['testBrowser'] ) ) $seleniumSettings['testBrowser'] = 'firefox'; |
| 182 | + if ( !isset( $seleniumSettings['jUnitLogFile'] ) ) $seleniumSettings['jUnitLogFile'] = false; |
173 | 183 | |
174 | 184 | // Setup Selenium class |
175 | 185 | $this->selenium = new Selenium( ); |
— | — | @@ -180,6 +190,7 @@ |
181 | 191 | $this->selenium->setUser( $this->getOption( 'username', $seleniumSettings['username'] ) ); |
182 | 192 | $this->selenium->setPass( $this->getOption( 'userPassword', $seleniumSettings['userPassword'] ) ); |
183 | 193 | $this->selenium->setVerbose( $this->hasOption( 'verbose' ) ); |
| 194 | + $this->selenium->setJUnitLogFile( $this->getOption( 'jUnitLogFile', $seleniumSettings['jUnitLogFile'] ) ); |
184 | 195 | |
185 | 196 | if( $this->hasOption( 'list-browsers' ) ) { |
186 | 197 | $this->listBrowsers(); |
Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.sample |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | testBrowser = "firefox" |
13 | 13 | startserver = |
14 | 14 | stopserver = |
| 15 | +jUnitLogFile = |
15 | 16 | |
16 | 17 | [SeleniumTests] |
17 | 18 | |
Index: trunk/phase3/maintenance/tests/selenium/Selenium.php |
— | — | @@ -21,6 +21,7 @@ |
22 | 22 | protected $pass; |
23 | 23 | protected $timeout = 30000; |
24 | 24 | protected $verbose; |
| 25 | + protected $junitlogfile; //processed by phpUnderControl |
25 | 26 | |
26 | 27 | /** |
27 | 28 | * @todo this shouldn't have to be static |
— | — | @@ -136,6 +137,14 @@ |
137 | 138 | $this->browsers = $availableBrowsers; |
138 | 139 | } |
139 | 140 | |
| 141 | + public function setJUnitLogfile( $junitlogfile ) { |
| 142 | + $this->junitlogfile = $junitlogfile; |
| 143 | + } |
| 144 | + |
| 145 | + public function getJUnitLogfile( ) { |
| 146 | + return $this->junitlogfile; |
| 147 | + } |
| 148 | + |
140 | 149 | public function setBrowser( $b ) { |
141 | 150 | if ( !isset( $this->browsers[$b] ) ) { |
142 | 151 | throw new MWException( "Invalid Browser: $b.\n" ); |
Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | testBrowser = "firefox" |
16 | 16 | startserver = |
17 | 17 | stopserver = |
| 18 | +jUnitLogFile = |
18 | 19 | |
19 | 20 | [testSuite] |
20 | 21 | |
Index: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php |
— | — | @@ -48,6 +48,7 @@ |
49 | 49 | $seleniumSettings['startserver'] = $configArray['SeleniumSettings']['startserver']; |
50 | 50 | $seleniumSettings['stopserver'] = $configArray['SeleniumSettings']['stopserver']; |
51 | 51 | $seleniumSettings['seleniumserverexecpath'] = $configArray['SeleniumSettings']['seleniumserverexecpath']; |
| 52 | + $seleniumSettings['jUnitLogFile'] = $configArray['SeleniumSettings']['jUnitLogFile']; |
52 | 53 | |
53 | 54 | wfRestoreWarnings(); |
54 | 55 | } |