r74755 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74754‎ | r74755 | r74756 >
Date:00:42, 14 October 2010
Author:mglaser
Status:ok
Tags:
Comment:
added support for junit log file output, which is neede by phpUnderControl
Modified paths:
  • /trunk/phase3/maintenance/tests/RunSeleniumTests.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/Selenium.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample (modified) (history)
  • /trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.sample (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/tests/RunSeleniumTests.php
@@ -29,9 +29,9 @@
3030 require_once( dirname( dirname( __FILE__ ) )."/Maintenance.php" );
3131 require_once( 'PHPUnit/Framework.php' );
3232 require_once( 'PHPUnit/Extensions/SeleniumTestCase.php' );
 33+require_once( 'PHPUnit/Util/Log/JUnit.php' );
3334 require_once( dirname( __FILE__ ) . "/selenium/SeleniumServerManager.php" );
3435
35 -
3636 class SeleniumTester extends Maintenance {
3737 protected $selenium;
3838 protected $serverManager;
@@ -51,6 +51,7 @@
5252 $this->addOption( 'verbose', 'Be noisier.' );
5353 $this->addOption( 'startserver', 'Start Selenium Server (on localhost) before the run.' );
5454 $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 );
5556 $this->deleteOption( 'dbpass' );
5657 $this->deleteOption( 'dbuser' );
5758 $this->deleteOption( 'globals' );
@@ -111,9 +112,13 @@
112113 protected function runTests( $seleniumTestSuites = array() ) {
113114 $result = new PHPUnit_Framework_TestResult;
114115 $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+ }
115120
116121 foreach ( $seleniumTestSuites as $testSuiteName => $testSuiteFile ) {
117 - require( $testSuiteFile );
 122+ require( $testSuiteFile );
118123 $suite = new $testSuiteName();
119124 $suite->addTests();
120125
@@ -124,6 +129,10 @@
125130 throw new MWException( $e->getMessage() );
126131 }
127132 }
 133+
 134+ if ( $this->selenium->getJUnitLogFile() ) {
 135+ $jUnitListener->flush();
 136+ }
128137 }
129138
130139 public function execute() {
@@ -169,6 +178,7 @@
170179 if ( !isset( $seleniumSettings['username'] ) ) $seleniumSettings['username'] = '';
171180 if ( !isset( $seleniumSettings['userPassword'] ) ) $seleniumSettings['userPassword'] = '';
172181 if ( !isset( $seleniumSettings['testBrowser'] ) ) $seleniumSettings['testBrowser'] = 'firefox';
 182+ if ( !isset( $seleniumSettings['jUnitLogFile'] ) ) $seleniumSettings['jUnitLogFile'] = false;
173183
174184 // Setup Selenium class
175185 $this->selenium = new Selenium( );
@@ -180,6 +190,7 @@
181191 $this->selenium->setUser( $this->getOption( 'username', $seleniumSettings['username'] ) );
182192 $this->selenium->setPass( $this->getOption( 'userPassword', $seleniumSettings['userPassword'] ) );
183193 $this->selenium->setVerbose( $this->hasOption( 'verbose' ) );
 194+ $this->selenium->setJUnitLogFile( $this->getOption( 'jUnitLogFile', $seleniumSettings['jUnitLogFile'] ) );
184195
185196 if( $this->hasOption( 'list-browsers' ) ) {
186197 $this->listBrowsers();
Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.sample
@@ -11,6 +11,7 @@
1212 testBrowser = "firefox"
1313 startserver =
1414 stopserver =
 15+jUnitLogFile =
1516
1617 [SeleniumTests]
1718
Index: trunk/phase3/maintenance/tests/selenium/Selenium.php
@@ -21,6 +21,7 @@
2222 protected $pass;
2323 protected $timeout = 30000;
2424 protected $verbose;
 25+ protected $junitlogfile; //processed by phpUnderControl
2526
2627 /**
2728 * @todo this shouldn't have to be static
@@ -136,6 +137,14 @@
137138 $this->browsers = $availableBrowsers;
138139 }
139140
 141+ public function setJUnitLogfile( $junitlogfile ) {
 142+ $this->junitlogfile = $junitlogfile;
 143+ }
 144+
 145+ public function getJUnitLogfile( ) {
 146+ return $this->junitlogfile;
 147+ }
 148+
140149 public function setBrowser( $b ) {
141150 if ( !isset( $this->browsers[$b] ) ) {
142151 throw new MWException( "Invalid Browser: $b.\n" );
Index: trunk/phase3/maintenance/tests/selenium/selenium_settings.ini.php52.sample
@@ -14,6 +14,7 @@
1515 testBrowser = "firefox"
1616 startserver =
1717 stopserver =
 18+jUnitLogFile =
1819
1920 [testSuite]
2021
Index: trunk/phase3/maintenance/tests/selenium/SeleniumConfig.php
@@ -48,6 +48,7 @@
4949 $seleniumSettings['startserver'] = $configArray['SeleniumSettings']['startserver'];
5050 $seleniumSettings['stopserver'] = $configArray['SeleniumSettings']['stopserver'];
5151 $seleniumSettings['seleniumserverexecpath'] = $configArray['SeleniumSettings']['seleniumserverexecpath'];
 52+ $seleniumSettings['jUnitLogFile'] = $configArray['SeleniumSettings']['jUnitLogFile'];
5253
5354 wfRestoreWarnings();
5455 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r75556r74753, r74755, r75254 added new settings, but didn't update SeleniumConfigur...platonides15:51, 27 October 2010

Status & tagging log