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

Commit 26ee7ec

Browse files
Monal5031ayushgarg1804
authored andcommitted
Document automated testing in VMS (#782)
1 parent ee0b24e commit 26ee7ec

17 files changed

+971
-68
lines changed

aut_docs/Design_Document.md

+31
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,34 @@ The QA process is divided as follows:
4747

4848
- To follow up changes in UI with changes in tests, the modifications need to be made only
4949
in the relevant locators/urls/page file.
50+
51+
- Addition of any new view implies that a pom `page` and `locator` need to be created.
52+
53+
- Similarly, modifying any view implies that the corresponding `page` and `locator` will
54+
also need to be modified.
55+
56+
## Important points regarding creation of new Test Class:
57+
58+
- As mentioned earlier, each test class corresponds to a view which has a corresponding
59+
pom page and locator.
60+
61+
- When creating a new test class, first identify the view the class is being created for,
62+
and create corresponding pom page and locator.
63+
64+
- Similarly, if you are modifying the existing templates make sure you update the corresponding
65+
pom page and locators.
66+
67+
- Each Test Class has `setUpClass` and `tearDownClass` class methods which should initiate and
68+
quit the WebDriver objects respectively.
69+
70+
- POM page should be linked to the Test Class in the `setUpClass` method itself and WebDriverWait
71+
if needed in the tests should also be initiated in this method only.
72+
73+
- If in the tests you are logging in as admin or volunteer make sure to `logout` in the `tearDown`
74+
method of the Test Class.
75+
76+
- Use of implicit waits should always be avoided unless needed in an extreme case and has the
77+
approval of a maintainer. If wait is needed use explicit waits instead.
78+
79+
- Tests in normal mode might fail if all are executed at once, but if a test is fails in
80+
`HEADLESS` mode then the test is wrong and should be corrected accordingly.

aut_docs/Documented_Failures.md

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
There are a few tests which have been commented out currently to avoid Travis CI build failure:
2+
3+
| File | App/Model | Test name | Reason/Related issue |
4+
|:----------------------------:|:-----------------:|:-------------------------------------------------------------------:|:-------------------------------------------------:|
5+
| test_settings.py | Administrator | test_duplicate_event | Logic not yet implemented |
6+
| test_settings.py | Administrator | test_duplicate_job | Logic not yet implemented |
7+
| test_formFields.py | Administrator | test_field_value_retention_for_event | [#742](https://github.com/systers/vms/issues/742) |
8+
| test_formFields.py | Administrator | test_field_value_retention_for_job | [#742](https://github.com/systers/vms/issues/742) |
9+
| test_formFields.py | Administrator | test_field_value_retention_for_shift | [#742](https://github.com/systers/vms/issues/742) |
10+
| test_report.py | Administrator | test_check_intersection_of_fields | Test is giving inconsistent results, probably issue in logic|
11+
| test_volunteerProfile.py | Volunteer | test_valid_upload_resume | [#776](https://github.com/systers/vms/issues/776)|
12+
| test_volunteerProfile.py | Volunteer | test_corrupt_resume_uploaded | [#776](https://github.com/systers/vms/issues/776)|
13+
| test_functional_admin.py | Registration | test_field_value_retention_in_first_name_state_phone_organization | [#763](https://github.com/systers/vms/issues/763)|
14+
| test_functional_admin.py | Registration | test_field_value_retention_in_last_name_address_city_country | [#763](https://github.com/systers/vms/issues/763)|
15+
| test_functional_volunteer.py | Registration | test_field_value_retention_in_first_name_state_phone_organization | [#763](https://github.com/systers/vms/issues/763)|
16+
| test_functional_volunteer.py | Registration | test_field_value_retention_in_last_name_address_city_country | [#763](https://github.com/systers/vms/issues/763)|
17+
| test_unit.py | Shift | test_invalid_model_create | [#743](https://github.com/systers/vms/issues/743)|
18+
| test_unit.py | VolunteerShift | test_invalid_model_create | [#743](https://github.com/systers/vms/issues/743)|

aut_docs/Documented_failures.md

-15
This file was deleted.

aut_docs/Installation_Setup.md

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
## Steps to run tests:
2+
3+
A one-time setup requires the following four steps:
4+
5+
- Install python,
6+
```bash
7+
sudo apt-get install python3.6
8+
```
9+
10+
- Install virtual environment
11+
```bash
12+
sudo apt-get install virtualenv
13+
```
14+
15+
- Clone the VMS project
16+
```bash
17+
git clone https://github.com/systers/vms.git
18+
```
19+
20+
- Create python3.6 virtual environment
21+
```bash
22+
virtualenv -p python3.6 venv
23+
```
24+
25+
Following points are needed to start a testing session:
26+
27+
- Activate virtual environment
28+
```bash
29+
source venv/bin/activate
30+
```
31+
- Install all python dependencies
32+
```bash
33+
pip install -r requirements.txt
34+
```
35+
36+
:Note: If you face any errors, do not open a new issue and ask for help on slack with full error logs.
37+
38+
- Change directory to VMS code
39+
```bash
40+
cd vms/
41+
```
42+
43+
- Create migrations for database
44+
```bash
45+
python manage.py makemigrations auth volunteer administrator organization event job shift registration
46+
```
47+
48+
- Apply migrations to database
49+
```bash
50+
python manage.py migrate --noinput --traceback --settings=vms.settings
51+
```
52+
53+
- Check that the project is running correctly by browsing to
54+
```
55+
http://127.0.0.1:8000
56+
```
57+
after running the command
58+
```bash
59+
python manage.py runserver
60+
```
61+
62+
- Automated tests in VMS require you to setup geckodriver in your path. For that, either run this command in root of project:
63+
```bash
64+
bash setup-geckodriver.sh
65+
```
66+
OR run these commands:
67+
```bash
68+
wget https://github.com/mozilla/geckodriver/releases/download/v0.20.1/geckodriver-v0.20.1-linux64.tar.gz
69+
tar -xzvf geckodriver-v0.20.1-linux64.tar.gz
70+
sudo mv geckodriver /usr/local/bin
71+
```
72+
:Note: If you are using Windows then see this link to configure geckodriver in your environment https://stackoverflow.com/a/40208762
73+
74+
- To execute all tests VMS, use this command:
75+
```bash
76+
python manage.py test -v 2
77+
```
78+
79+
- To execute tests in a particular file use:
80+
```bash
81+
python manage.py test <app_name> -v 2
82+
```
83+
84+
- To execute a test file inside a app use:
85+
```bash
86+
python manage.py test <app_name>.tests.<test_file_name> -v 2
87+
```
88+
89+
- For the automated tests, f geckodriver has been configured correctly then during simulation of tests the firefox browser will automatically open up and perform the actions and close at the end of the test.
90+
91+
- If all tests pass, `OK` will be received at the end.
92+
93+
- For automated tests, if any of the tests fail its not necessary that there is something wrong. To confirm if the the test is actually wrong you have to test it in headless mode.
94+
95+
:Note: For automated testing, currently VMS uses the Firefox version 60, selenium version 3.4.0 and geckodriver version 0.20.1

aut_docs/Setup.md

-20
This file was deleted.

0 commit comments

Comments
 (0)