Skip to content

Commit 9d0d3f0

Browse files
authored
Add automated test best practice guidelines (#1799)
1 parent cea6c7d commit 9d0d3f0

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

+30-1
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,43 @@ To run a manual hook like `shellcheck` manually, run:
3636
pre-commit run --all-files --hook-stage manual shellcheck
3737
```
3838

39-
## Prose test numbering
39+
## Prose Test Numbering
4040

4141
When numbering prose tests, always use relative numbered bullets (`1.`). New tests must be appended at the end of the
4242
test list, since drivers may refer to existing tests by number.
4343

4444
Outdated tests must not be removed completely, but may be marked as such (e.g. by striking through or replacing the
4545
entire test with a note (e.g. *Removed*).
4646

47+
## Automated Test Best Practices
48+
49+
### Immutability of Existing Tests
50+
51+
**Do not modify existing tests**, unless they are testing incorrect behavior. Default to creating new tests or test
52+
files instead of altering existing ones.
53+
54+
Test files can only be deleted once no driver runs them anymore. In the meantime, for cases where a spec change removes
55+
functionality:
56+
57+
- **Unified Tests:** Use `runOnRequirements` to ensure tests are only executed by drivers supporting the required
58+
functionality.
59+
- **Non-Unified Tests (e.g., SDAM):** Drivers should skip tests that no longer apply to them.
60+
61+
### Test Isolation
62+
63+
When creating a new test, only test functionality directly related to the new spec requirements. Omit irrelevant fields
64+
in command expectations.
65+
66+
This makes tests more resilient against spec updates and avoids needing to change tests down the line.
67+
68+
### Schema Version Usage
69+
70+
Use the **lowest possible schema version** for each test.
71+
72+
Do NOT default to using the latest unified test format schema version, as the drivers may not all implement it. Use the
73+
oldest schema version that supports all functionality used in the test, even if it requires creating a new test file
74+
with a lower schema version.
75+
4776
## Building Documents
4877

4978
We use [mkdocs](https://www.mkdocs.org/) to render the documentation. To see a live view of the documentation, in a

0 commit comments

Comments
 (0)