Skip to content
This repository was archived by the owner on Jan 26, 2021. It is now read-only.

Commit 4e9d0c6

Browse files
Merge pull request #315 from smarshy/update-test
Addition of updated automated tests to vms
2 parents cb47cdd + d02d431 commit 4e9d0c6

40 files changed

+6619
-2
lines changed

aut_docs/Design_Document.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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.

docs/Installation Guide.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ Start the development server by running the command (this runs the development s
294294

295295
You can now try out the project by going to [http://localhost:8001/home](http://localhost:8001/home) on a browser on your local machine.
296296

297-
## Run Unit Tests
297+
## Run Unit and Functional Tests
298298

299-
You can also run unit tests by running the command:
299+
You can also run unit and functional tests by running the command:
300300

301301
python manage.py test name_of_app_here
302302

@@ -314,6 +314,18 @@ python manage.py test shift
314314
python manage.py test organization
315315
```
316316

317+
If you want to run only unit tests for an app, refer to its test_services file using the dot notation.
318+
319+
For example, if you want to run unit tests for the event app:
320+
```
321+
python manage.py test event.tests.test_services
322+
```
323+
324+
Smilarly, for job app it would be:
325+
```
326+
python manage.py test job.tests.test_services
327+
```
328+
317329
If you want to run all unit tests, run this command:
318330

319331
python manage.py test

requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
coverage==3.7.1
2+
coveralls==0.5
3+
Django==1.7.4
4+
docopt==0.6.2
5+
psycopg2==2.5.4
6+
PyYAML==3.11
7+
requests==2.7.0
8+
selenium==2.53.1

vms/administrator/tests/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)