|Version 8 (modified by 10 years ago) ( diff ),|
Sahana Eden Testing functionality documentation:
Table of Contents
Introducing automated testing system built inside Sahana Eden (S3) framework.
"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:
How does it work?
The system relies on Selenium web driver and IDE to execute and/or create automated test scripts. 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.
These tests are stored in
Installation of the testing environment in your machine
In order to execute the automated Selenium powered test scripts, you must install the Selenium Web Drivers into Python as packages.
Windows & MAC OSx installation:
Download latest Selenium package:
2) Extract it
3) CMD/Terminal bash:
cd selenium-2.20.0 python setup.py install
Running / Executing Automated test scripts:
In Sahana Eden, the testing system is implemented in the directory: eden/modules/tests/
Now that you have installed all the Selenium packages to your Python on your machine, you can now run them to test Eden module(s) functionalities.
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:
cd web2py python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py
Run a single test script for the Eden application:
cd web2py python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A mytestfunction
Writing / Creating your own test scripts:
We aim to make it as easy as possible to write additional tests, which can easily be plugged into the testing suite or/and executed separately.
Use the Selenium IDE to generate python codes.
An example has been created:
New tests should be stored in a subfolder per module, adding the foldername to
eden/modules/tests/__init__.py & creating an
__init__.py 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)
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:
- Store results in a format suitable for use by CI
- Namespacing of tests
- Include timings
- Run from Nose?
- TestCases - User Testing - List of things to test
- http://code.google.com/p/selenium/wiki/PageObjects - Style suggestion