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

Addition of updated automated tests to vms #315

Merged
merged 8 commits into from
Jun 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions aut_docs/Design_Document.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Automated Testing for VMS

The QA process is divided as follows:

- Continuous Intergation: Used travis to setup CI for VMS Project
- Functional Testing: Used Selnium to write UI tests from an end-users perspective.(black-box tests)
- Unit Testing: Valeria is writing unit-tests for the codebase.(white-box tests)

## Few important points regarding CI:

- `.travis.yml` is the config file to run the travis build
- Build can be viewed at `http://travis.org/jayesh92/vms`
- Status would be reflected in the badge in `README.md`

## Few important points regarding Functional Testing:

- Selenium, a browser automation tool is used to simulate the functionality.
python APIs for selnium are used in the tests.

- Django provides a class `LiveServerTestCase`. What this does is that, It
setups a Virtual Django Sever in the background which can be used by
selenium to run tests.

- So, each testcase Class inherits `LiveServerTestCase`, Contains a `setUp`
and `tearDown` method to instantiate and end live-server respectively.
Each testcase in the class begins with `test`.

- Each Test Class covers a view. Class name represents the name of the view
in nav-bar. Test suite for a view is contained in `tests` folder of the app
containing the view. For Ex: `Volunteer Search` tab in the nav-bar of an
admin user redirects to `http://127.0.0.1:8000/volunteer/search/`, so
the corresponding tests for this view would be in `VolunteerSearch` class
in `tests` folder of `volunteer` app.

- Each app contains a `tests` folder containing the unit-tests and functional
tests and an `__init__.py` to let django consider it as a package.

- Currently, only functional tests for admin views have been written.

## Steps to run tests:

- Currently, used `python 2.7`
- Clone project: `git clone https://github.com/systers/vms.git`
- In the root folder of the project, startup a new virtual environment
`virtualenv -p /usr/bin/python2.7 venv`
- Activate virtualenv, `source venv/bin/activate`
- Install dependencies: `pip install -r requirements.txt`
- `cd vms`
- To run, `python manage.py runserver`. Browse
`http://127.0.0.1:8000`
- To execute tests `python manage.py test`. This will run all unit-tests and
all functional-tests across all apps. To execute tests of only a particular
app, run `python manage.py test <app_name>`
- If all tests pass, `OK` will be received at the end.
- For functional tests, a firefox window for each test will open up
automatically and close after simulation of tests.

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.
16 changes: 14 additions & 2 deletions docs/Installation Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ Start the development server by running the command (this runs the development s

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.

## Run Unit Tests
## Run Unit and Functional Tests

You can also run unit tests by running the command:
You can also run unit and functional tests by running the command:

python manage.py test name_of_app_here

Expand All @@ -314,6 +314,18 @@ python manage.py test shift
python manage.py test organization
```

If you want to run only unit tests for an app, refer to its test_services file using the dot notation.

For example, if you want to run unit tests for the event app:
```
python manage.py test event.tests.test_services
```

Smilarly, for job app it would be:
```
python manage.py test job.tests.test_services
```

If you want to run all unit tests, run this command:

python manage.py test
Expand Down
8 changes: 8 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
coverage==3.7.1
coveralls==0.5
Django==1.7.4
docopt==0.6.2
psycopg2==2.5.4
PyYAML==3.11
requests==2.7.0
selenium==2.53.1
Empty file.
Loading