|
| 1 | +# Testing Documentation |
| 2 | + |
| 3 | +This codebase is setup with a **high standard testing**. |
| 4 | +Which automate the testing of almost complte codebase. |
| 5 | + |
| 6 | +Here we explain how we put different testing in our codebase. |
| 7 | + |
| 8 | +Wishing you Happy Reading :) from @jitendra-ky |
| 9 | + |
| 10 | +## Django API Endpoint Tests |
| 11 | + |
| 12 | +### Overview |
| 13 | + |
| 14 | +Django API endpoint tests are used to test individual API endpoints of the application to ensure they work as expected. |
| 15 | + |
| 16 | +### Running Django API Endpoint Tests |
| 17 | + |
| 18 | +To run the Django API endpoint tests, use the following command: |
| 19 | + |
| 20 | +```bash |
| 21 | +python manage.py test |
| 22 | +``` |
| 23 | + |
| 24 | +### Test Framework |
| 25 | + |
| 26 | +We use Django's built-in test framework for testing API endpoints. |
| 27 | + |
| 28 | +## UI Tests |
| 29 | + |
| 30 | +### Overview |
| 31 | + |
| 32 | +UI tests are used to test the user interface of the application using Selenium. |
| 33 | + |
| 34 | +> With `selenium` i automate almost complete UI (User Interface). |
| 35 | +> So no more headache or visiting every page and checking, if it is woring corrently or not after making every small change. |
| 36 | +
|
| 37 | +### Running UI Tests |
| 38 | + |
| 39 | +To run the UI tests: |
| 40 | + |
| 41 | +> make sure django server is running on localhost:8000. |
| 42 | +> you can run the server with `python manag.epy runserver` |
| 43 | +
|
| 44 | +```bash |
| 45 | +./tools/uitest |
| 46 | +``` |
| 47 | + |
| 48 | +### Test Framework |
| 49 | + |
| 50 | +We use Selenium for UI testing. |
| 51 | + |
| 52 | +Selenium is a powerful tool for **controlling a web browser through the program**. It is functional for all browsers, works on all major OS, and its scripts can be written in various programming languages such as **Python**, Java, C#, etc. Selenium is primarily used for **automating web applications for testing purposes** but is certainly not limited to just that. Boring web-based administration tasks can also be automated as well. |
| 53 | + |
| 54 | +## Linting |
| 55 | + |
| 56 | +### Overview |
| 57 | + |
| 58 | +Linting is used to ensure code quality and adherence to coding standards. |
| 59 | + |
| 60 | +### Running Linting |
| 61 | + |
| 62 | +To run the linting checks for python code, use the following command: |
| 63 | + |
| 64 | +```bash |
| 65 | +ruff check --force-exclude $(git ls-files '*.py') |
| 66 | +``` |
| 67 | + |
| 68 | +To run ESLint and Prettier check. |
| 69 | + |
| 70 | +```bash |
| 71 | +npm run test |
| 72 | +``` |
| 73 | + |
| 74 | +### Tools |
| 75 | + |
| 76 | +- Ruff for linting Python code. |
| 77 | +- ESLint for linting JavaScript code. |
| 78 | +- Prettier for code formattng. |
| 79 | + |
| 80 | +## CI/CD Pipeline |
| 81 | + |
| 82 | +### Overview |
| 83 | + |
| 84 | +With Github Actions We automation to run all the tests on every pull request. |
| 85 | + |
| 86 | +### Pipeline Configuration |
| 87 | + |
| 88 | +The pipeline is configured using GitHub Actions. The configuration file is located at `.github/workflows/tests_ci.yml`. |
0 commit comments