Integration Testing
Contents
Installing and Configuring your Web Test Environment
Firefox
Selenium tests can best be developed using a plug-in for the Firefox browser. This plug-in can record all actions you perform on a web page and replay them. It also contains an editor to manually extend or adapt your test cases.
Once the code Selenium code (they call it Selenese) has been developed, it can be executed in all browsers.
This means that you should have the latest version of Firefox installed.
Selenium IDE
Download the latest Selenium IDE Firefox Plugin from the Selenium Website. You won't find the word "Firefox" there. Just download "Selenium IDE", that's the plug-in.
Don't use the plug-in you might find on the Firefox add-on pages as this is often outdated.
Install the plug-in into FireFox.
Restart FireFox.
Selenium RC
- download latest Selenium RC from the Selenium Website
- extract into some folder (i.e. .../selenium-rc)
- install as a service (see http://unintelligible.org/blog/2009/07/28/installing-selenium-rc-as-a-windows-service/)
- change the service user if required
- check "allow data exchange between service and desktop"
- start the service
Developing Web Tests (Tutorial)
My software environment
I used the following software configuration when I created this tutorial:
- Firefox 3.5.3
- Selenium IDE 1.0.2
- Eclipse Galileo with PDT 2.0
- PHPUnit 3.4
- PHP 5.2.11
Create "Selenese" for a test case
- open Selenium IDE Sidebar
- record your test in the Selenium IDE
- Options->Format->PHP – Selenium RC
- Copy the test code (only the test method) to the clipboard
Create a test case that extends OjsWebTest
- copy the test code into the method
- correct the following manually:
- use assertTitleEquals(), assertLocationEquals(), etc. rather than assertEquals(..., $this->getTitle() / getLocation())
- use waitForLocation() when you use redirects
- if you used the waitForLocation command in Selenium IDE then replace the generated for loop with a call to waitForLocation()
- use ...AndWait() rather than waitForPageToLoad()