Version 5 (modified by coldblooded, 12 years ago) ( diff )



"A bug is a test case you haven't written yet"
"Unit Tests allow merciless refactoring"

Test-Driven Development is a programming styles which says that you 1st write your test cases (from the specs) & then proceed to make them pass.

Selenium provides the ability to test Sahana Eden as users see it - namely through a web browser. This therefore does end-to-end Functional Testing, however it can also be sued as Unit Testing

We are building our framework around the new WebDriver, despite having some legacy code in the older format:

These tests are stored in eden/modules/tests


Install Selenium Python Client Driver into your running Python:


tar zxvf selenium-2.20.tar.gz
cd selenium-2.20
python install

Latest edit on how to install Selenium Python Client Driver in your Python enviroment:

Download selenium 2.20.0 from: into an appropriate folder (for example: selenium-2.20)

cd selenium-2.20 (cd into the folder you just downloaded selenium 2.20 in)
sudo python install (install Selenium Python Client Driver)

You should now have Selenium in your environment

Running Tests

Before running the Selenium scripts, you should put your database into a known state:


For the whole test suite, it is assumed that you are using:

deployment_settings.base.prepopulate = 2

Run the whole test suite for the 'eden' application:

python -S eden -M -R applications/eden/modules/tests/

Run a single test for the 'eden' application:

python -S eden -M -R applications/eden/modules/tests/ -A mytestfunction

Writing Tests

We aim to make it as easy as possible to write additional tests, which can easily be plugged into the suite.

An example has been created: eden/modules/tests/hrm/

New tests should be stored in a subfolder per module, adding the foldername to eden/modules/tests/ & creating an in the subfolder.

The key is to make tests which are as least fragile as possible through:

  • State (we should eb able to run individual tests easilty, which check their current state as-required)
  • Deployment_Settings
  • Localisation
  • Theme

This suggests refactoring tests to centralise common elements into a library to mean fixes should only happen in 1 place.

There are a number of possible selectors to use to find your elements...the 'ID' may be the most stable, so don't be afraid of patching the code to add IDs where you'd like to be able to reach them reliably:


See Also

Note: See TracWiki for help on using the wiki.