Changes between Version 7 and Version 8 of DeveloperGuidelines/Testing/Selenium
- Timestamp:
- 05/04/12 04:49:28 (13 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DeveloperGuidelines/Testing/Selenium
v7 v8 1 = Testing=1 = Sahana Eden Testing functionality documentation: = 2 2 [[TOC]] 3 '''Introducing automated testing system built inside Sahana Eden (S3) framework.''' 4 3 5 "A bug is a test case you haven't written yet" [[BR]] 4 6 "Unit Tests allow merciless [http://diveintopython.org/refactoring/refactoring.html refactoring]" … … 11 13 * http://seleniumhq.org/docs/appendix_migrating_from_rc_to_webdriver.html#why-migrate-to-webdriver 12 14 15 == How does it work? == 16 The system relies on Selenium web driver and IDE to execute and/or create automated test scripts. 17 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. 18 13 19 These tests are stored in {{{eden/modules/tests}}} 14 20 15 == Installation == 16 Install Selenium Python Client Driver into your running Python: 17 * http://selenium.googlecode.com/svn/trunk/docs/api/py/index.html 21 == Installation of the testing environment in your machine == 22 23 In order to execute the automated Selenium powered test scripts, you must install the Selenium Web Drivers into Python as packages.[[BR]] 24 25 ''Windows & MAC OSx installation:''[[BR]] 26 27 Download latest Selenium package:[[BR]] 28 1) http://pypi.python.org/packages/source/s/selenium/selenium-2.20.0.tar.gz [[BR]] 29 2) Extract it[[BR]] 30 3) CMD/Terminal bash: 18 31 {{{ 19 pip install -U selenium20 }}}21 or22 {{{23 wget http://pypi.python.org/packages/source/s/selenium/selenium-2.20.0.tar.gz24 tar zxvf selenium-2.20.0.tar.gz25 32 cd selenium-2.20.0 26 33 python setup.py install 27 34 }}} 28 == Running Tests == 35 36 == Running / Executing Automated test scripts: == 37 In Sahana Eden, the testing system is implemented in the directory: eden/modules/tests/ [[BR]] 38 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. [[BR]][[BR]] 39 29 40 Before running the Selenium scripts, you should put your database into a known state: 30 41 {{{ … … 36 47 deployment_settings.base.prepopulate = 2 37 48 }}} 49 Run the whole test suite for the Eden application:[[BR]] 38 50 39 Run the whole test suite for the 'eden' application:40 51 {{{ 41 52 cd web2py 42 53 python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py 43 54 }}} 44 Run a single test for the 'eden' application: 55 56 Run a single test script for the Eden application:[[BR]] 57 45 58 {{{ 46 59 cd web2py 47 60 python web2py.py -S eden -M -R applications/eden/modules/tests/suite.py -A mytestfunction 48 61 }}} 62 [[BR]] 49 63 50 == Writing Tests==51 We aim to make it as easy as possible to write additional tests, which can easily be plugged into the suite.64 == Writing / Creating your own test scripts:== 65 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.[[BR]] 52 66 53 An example has been created: {{{eden/modules/tests/hrm/staff.py}}} 67 Use the Selenium IDE to generate python codes. [[BR]] 68 69 An example has been created: {{{eden/modules/tests/hrm/hrm001.py}}} 54 70 55 71 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.