From 83f9e8f2b4c4b3c64fc4d9c5762076af4659e4b3 Mon Sep 17 00:00:00 2001 From: Lilleman auf Larv Date: Tue, 1 Dec 2026 17:06:00 +0100 Subject: [PATCH] =?UTF-8?q?Answer=20prose=20round=201:=200=20=F0=9F=94=B4,?= =?UTF-8?q?=202=20=F0=9F=9F=A1=20(0=20misread);=20lead=20with=20the=20cond?= =?UTF-8?q?ition,=20split=20off=20the=20timeout,=20name=20each=20example's?= =?UTF-8?q?=20parts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- principles/technical-principles.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/principles/technical-principles.md b/principles/technical-principles.md index b4f7f273..feb9981b 100644 --- a/principles/technical-principles.md +++ b/principles/technical-principles.md @@ -62,7 +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. + - When another goroutine, process or queue sets the state a test reads, the test waits for a signal that the code under test or its fake sends, such as a message on a channel or a callback. Give the wait a timeout whose only effect is to fail the test when the signal never comes. Reading the state straight after the call that starts the work races with that work, and polling with sleeps breaks the rule above. BANNED: `assert len(server.connections) == 3` right after the client opens three connections. GOOD: the fake server sends on a channel each time it accepts a connection, and the test receives from that channel three times, each receive 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.