Add a test-waits-on-a-signal bullet to the technical principles
CI / tests (pull_request) Has been cancelled
CI / tests (pull_request) Has been cancelled
This commit is contained in:
@@ -62,6 +62,7 @@
|
||||
- Every escaped bug becomes a test that fails without its fix.
|
||||
- Write no test that no real bug could fail: a constant's value, a list's length, the framework's own behaviour.
|
||||
- A test neither sleeps nor asserts on the wall clock, and seeds any randomness.
|
||||
- A test that reads state another goroutine, process or queue sets waits on a signal that the code under test or its fake sends, such as a channel or a callback, with a timeout that only fails the test. Reading the state straight after the call races with the other side, and a sleeping poll breaks the rule above. BANNED: `assert len(server.connections) == 3` right after the client calls. GOOD: the fake sends on a channel per connection, and the test receives three times, with a timeout.
|
||||
- For pure logic over many inputs, prefer a property test: a round trip, an invariant.
|
||||
- Changing tests and changing other code are two separate processes — be very careful about doing both at once.
|
||||
- Use properly randomised UUID v7s — never `aaaa-0000`-style placeholders.
|
||||
|
||||
Reference in New Issue
Block a user