Changes between Initial Version and Version 1 of DeveloperGuidelines/Testing/Selenium

03/27/12 09:30:43 (10 years ago)
Fran Boon

Initial version for new test framework


  • DeveloperGuidelines/Testing/Selenium

    v1 v1  
     1= Testing =
     3"A bug is a test case you haven't written yet" [[BR]]
     4"Unit Tests allow merciless [ refactoring]"
     6Test-Driven Development is a programming styles which says that you 1st write your test cases (from the [BluePrints specs]) & then proceed to make them pass.
     8Selenium 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
     10We are building our framework around the new WebDriver, despite having some legacy code in the older format:
     13These tests are stored in {{{eden/modules/tests}}}
     15== Installation ==
     16Install Selenium Python Client Driver into your running Python:
     19pip install -U selenium
     24tar zxvf selenium-2.20.tar.gz
     25cd selenium-2.20
     26python install
     29== Running Tests ==
     30Before running the Selenium scripts, you should put your database into a known state:
     35For the whole test suite, it is assumed that you are using:
     37deployment_settings.base.prepopulate = 2
     40Run the whole test suite for the 'eden' application:
     42python -S eden -M -R applications/eden/modules/tests/
     44Run a single test for the 'eden' application:
     46python -S eden -M -R applications/eden/modules/tests/ -A mytestfunction
     49== Writing Tests ==
     50We aim to make it as easy as possible to write additional tests, which can easily be plugged into the suite.
     52An example has been created: {{{eden/modules/tests/hrm/}}}
     54New tests should be stored in a subfolder per module, adding the foldername to {{{eden/modules/tests/}}} & creating an {{{}}} in the subfolder.
     56The key is to make tests which are as least fragile as possible through:
     57* State (we should eb able to run individual tests easilty, which check their current state as-required)
     58* Deployment_Settings
     59* Localisation
     60* Theme
     62This suggests refactoring tests to centralise common elements into a library to mean fixes should only happen in 1 place.
     64There 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:
     67== !ToDo ==
     68* Store results in a format suitable for use by CI
     69* Namespacing of tests
     70* Include timings
     71* Run from Nose?
     72 *
     74== See Also ==
     75 * TestCases - User Testing - List of things to test
     76 * - Style suggestion