Skip to content

Commit 61cc907

Browse files
committed
Add automated testing page
1 parent b492d90 commit 61cc907

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
4. [LTI - Learning Tools Interoperability Protocol](./recipes/lti.md)
2222
5. [CircleCI Build Guide](./recipes/circleci-build-guide.md)
2323

24+
## Guides
25+
26+
1. [Automated Testing](./recipes/automated-testing.md)
27+
2428
## 🙌 Want to contribute?
2529

2630
We are open to all kinds of contributions. If you want to:

recipes/automated-testing.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Automated Testing
2+
3+
## Types of Automated Tests
4+
5+
There are different approaches to testing and depending on the level of the
6+
entry point, we can split tests into following categories.
7+
8+
- **Unit Tests**
9+
- **Integration Tests**
10+
- **E2E Tests**
11+
- **Load/Performance Tests**
12+
- **Visual Tests**
13+
14+
*Note that some people can call these tests by different names, but for Studion
15+
internal purposes, this should be considered the naming convention.*
16+
17+
### Unit Tests
18+
19+
These are the most isolated tests that we can write. They should take a specific
20+
function/service/helper/module and test its functionality. Unit tests will
21+
usually require mocked data, but since we're testing that specific input produces
22+
specific output, the mocked data set should be minimal.
23+
24+
Unit testing is recommended for functions that contain a lot of logic and/or branching.
25+
It is convenient to test a specific function at the lowest level so if the logic
26+
changes, we can make minimal changes to the test suite and/or mocked data.
27+
28+
29+
### Integration Tests (API Tests)
30+
31+
This is the broadest test category. With these tests, we want to make sure our
32+
API contract is valid and the API returns the expected data. That means we write
33+
tests for the publically available endpoints.
34+
35+
**TODO**: do we want to add that we should run full backend for these type of tests?
36+
37+
**TODO**: do we want to write anything about mocking the DB data/seeds?
38+
39+
In these tests we should cover *at least* the following:
40+
- **authorization** - make sure only logged in users with correct role/permissions
41+
can access this endpoint
42+
- **success** - if we send correct data, the endpoint should return response that
43+
contains correct data
44+
- **failure** - if we send incorrect data, the endpoint should handle the exception
45+
and return appropriate error status
46+
47+
If the endpoint contains a lot of logic where we need to mock a lot of different
48+
inputs, it might be a good idea to cover that logic with unit tests. Unit tests
49+
will require less overhead and will provide better performance while at the same
50+
time decoupling logic testing and endpoint testing.
51+
52+
### E2E Tests
53+
54+
These tests are executed within a browser environment (Playwright, Selenium, etc.).
55+
The purpose of these tests is to make sure that interacting with the application UI
56+
produces the expected result.
57+
58+
Usually, these tests will cover a large portion of the codebase with least
59+
amount of code.
60+
Because of that, they can be the first tests to be added to a project that
61+
has no tests or has low test coverage.
62+
63+
These tests should not cover all of the use cases because they are the slowest to
64+
execute. If we need to test edge cases, we should try to implement those at a
65+
lower level, like integration or unit tests.
66+
67+
### Performance Tests
68+
69+
These types of tests will reproduce a usual user scenario and then simulate a group
70+
of concurrent users and measure the server's response.
71+
72+
They are typically used to stress test the infrastructure and measure the throughput
73+
of the application.
74+
75+
76+
### Visual Tests
77+
78+
The type of test where test runner navigates to browser page, takes screenshot
79+
and then compares the future screenshots with the reference screenshot.
80+
81+
These types of tests will cover a lot of ground with the least effort and
82+
can indicate a change in the app. The downside is that they're not very precise
83+
and the engineer needs to spend some time to determine the cause of the error.

0 commit comments

Comments
 (0)