|
| 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 |
0 commit comments