|
| 1 | +# Automated Testing for VMS |
| 2 | + |
| 3 | +The QA process is divided as follows: |
| 4 | + |
| 5 | +- Continuous Intergation: Used travis to setup CI for VMS Project |
| 6 | +- Functional Testing: Used Selnium to write UI tests from an end-users perspective.(black-box tests) |
| 7 | +- Unit Testing: Valeria is writing unit-tests for the codebase.(white-box tests) |
| 8 | + |
| 9 | +## Few important points regarding CI: |
| 10 | + |
| 11 | +- `.travis.yml` is the config file to run the travis build |
| 12 | +- Build can be viewed at `http://travis.org/jayesh92/vms` |
| 13 | +- Status would be reflected in the badge in `README.md` |
| 14 | + |
| 15 | +## Few important points regarding Functional Testing: |
| 16 | + |
| 17 | +- Selenium, a browser automation tool is used to simulate the functionality. |
| 18 | + python APIs for selnium are used in the tests. |
| 19 | + |
| 20 | +- Django provides a class `LiveServerTestCase`. What this does is that, It |
| 21 | + setups a Virtual Django Sever in the background which can be used by |
| 22 | + selenium to run tests. |
| 23 | + |
| 24 | +- So, each testcase Class inherits `LiveServerTestCase`, Contains a `setUp` |
| 25 | + and `tearDown` method to instantiate and end live-server respectively. |
| 26 | + Each testcase in the class begins with `test`. |
| 27 | + |
| 28 | +- Each Test Class covers a view. Class name represents the name of the view |
| 29 | + in nav-bar. Test suite for a view is contained in `tests` folder of the app |
| 30 | + containing the view. For Ex: `Volunteer Search` tab in the nav-bar of an |
| 31 | + admin user redirects to `http://127.0.0.1:8000/volunteer/search/`, so |
| 32 | + the corresponding tests for this view would be in `VolunteerSearch` class |
| 33 | + in `tests` folder of `volunteer` app. |
| 34 | + |
| 35 | +- Each app contains a `tests` folder containing the unit-tests and functional |
| 36 | + tests and an `__init__.py` to let django consider it as a package. |
| 37 | + |
| 38 | +- Currently, only functional tests for admin views have been written. |
| 39 | + |
| 40 | +## Steps to run tests: |
| 41 | + |
| 42 | +- Currently, used `python 2.7` |
| 43 | +- Clone project: `git clone https://github.com/systers/vms.git` |
| 44 | +- In the root folder of the project, startup a new virtual environment |
| 45 | + `virtualenv -p /usr/bin/python2.7 venv` |
| 46 | +- Activate virtualenv, `source venv/bin/activate` |
| 47 | +- Install dependencies: `pip install -r requirements.txt` |
| 48 | +- `cd vms` |
| 49 | +- To run, `python manage.py runserver`. Browse |
| 50 | + `http://127.0.0.1:8000` |
| 51 | +- To execute tests `python manage.py test`. This will run all unit-tests and |
| 52 | + all functional-tests across all apps. To execute tests of only a particular |
| 53 | + app, run `python manage.py test <app_name>` |
| 54 | +- If all tests pass, `OK` will be received at the end. |
| 55 | +- For functional tests, a firefox window for each test will open up |
| 56 | + automatically and close after simulation of tests. |
| 57 | + |
| 58 | +Note: The current setup uses one of the latest versions of Selenium. You will run into errors if the this version is incompatible with your firefox version and does not support it. In that case, follow [this](https://support.mozilla.org/en-US/kb/find-what-version-firefox-you-are-using) guide to find out your browser version and accordingly install a Selenium version compatible with it. |
0 commit comments