views:

500

answers:

1

I want to add a suite of Selenium tests as part of a global PHPUnit test suite for an application. I have hooked the suite of Selenium tests into the global AllTests.php file and everything runs fine whilst the Selenium server is running.

However, I would like the script to skip the Selnium tests if the Selenium server isn't running so other developers aren't forced to install Selenium server in order for the tests to run. I would normally try to connect within the setUp method of each testcase and mark the tests as skipped if this failed, but this seems to throw a RuntimeException with message:

The response from the Selenium RC server is invalid: ERROR Server Exception: sessionId should not be null; has this session been started yet?

Does anyone have a method for marking the Selenium tests as skipped in this scenario?

+1  A: 

You could use test dependencies that were introduced in PHPUnit 3.4.

Basically

  1. write a test that checks whether Selenium is up.
  2. If not, call $this->markTestAsSkipped().
  3. Make all your selenium requiring tests depend on this one.
Anti Veeranna