You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are two testing frameworks in place: one for the frontend (JavaScript and Node.js) and another for the backend (Python Django).
4
+
5
+
# Frontend testing
6
+
7
+
## Usage
8
+
9
+
To run the test suite, use the `test` command via the Node package manager (NPM):
10
+
11
+
```bash
12
+
npm test
13
+
```
14
+
15
+
This will execute Vitest. There are also other testing modes. To run the tests whenever the code changes using a file watcher, run:
16
+
17
+
```bash
18
+
npm run test:watch
19
+
```
20
+
21
+
And to get a coverage report:
22
+
23
+
```bash
24
+
npm run test:coverage
25
+
```
26
+
27
+
## Writing tests
28
+
29
+
The frontend tests are contained in the `ui_components/tests` directory and are organised to match the source code structure. Each test should test an isolated unit of code. Please read the [introduction to writing tests for Svelte](https://svelte.dev/docs/svelte/testing) and the [Svelte testing library](https://testing-library.com/docs/svelte-testing-library/intro).
30
+
31
+
# Backend testing
32
+
3
33
The test suite uses the Django testing tools. For more information, please read [Testing in Django](https://docs.djangoproject.com/en/5.1/topics/testing/) and
4
34
the further [Django testing examples](https://django-testing-docs.readthedocs.io/en/latest/index.html).
5
35
6
-
# Installation
36
+
##Installation
7
37
8
38
To install the necessary packages in your local development environment, use the `requirements-dev.txt` file.
Pleaser read the [running tests](https://docs.djangoproject.com/en/5.1/topics/testing/overview/#running-tests) section of the Django documentation.
19
49
@@ -22,22 +52,22 @@ python manage.py test home/tests --parallel=auto --failfast
22
52
python manage.py test survey/tests --parallel=auto --failfast
23
53
```
24
54
25
-
## Coverage reports
55
+
###Coverage reports
26
56
27
57
At the end of the GitHub Actions testing workflow, a coverage report will be generated using the [Coverage.py](https://coverage.readthedocs.io/) tool.
28
58
29
-
# Writing tests
59
+
##Writing tests
30
60
31
61
Please read the Django [writing tests section](https://docs.djangoproject.com/en/5.1/topics/testing/overview/#writing-tests) of the Django documentation. There are unit tests in the `./tests` directory of each Django application.
32
62
33
-
## Tests
63
+
###Tests
34
64
35
65
The tests are defined in each application in the `tests` directory, where each file is a Python script that contains tests for a different aspect of the app. The filenames must start with `test_`.
36
66
37
-
## Test cases
67
+
###Test cases
38
68
39
69
There are test case classes defined in the [`SORT.test.test_case`](SORT/test/test_case) module that contain useful methods for testing Django views and the application service layer in the SORT code.
40
70
41
-
## Object factories
71
+
###Object factories
42
72
43
73
There are factory utilities that are used to create mock objects of our Django models for testing in the [`SORT.test.model_factory`](SORT/test/model_factory) module. This uses the [Factory Boy](https://factoryboy.readthedocs.io/en/stable/index.html) library, which [supports the Django ORM](https://factoryboy.readthedocs.io/en/stable/orms.html#module-factory.django).
0 commit comments