Fake Clocks, Real Guarantees: Inside Go's synctest
The first time I reached for testing/synctest, I assumed it was a sleep helper with better manners. The public API is small enough to support that assumption:
synctest.Test(t, func(t *testing.T) { ... })
synctest.Wait()
synctest.Sleep(d) // new in Go 1.27
Three functions, one obvious guess: fake time, wrapped in test scaffolding. That guess is wrong. It isn’t a sleep helper, a goroutine wrapper, or a mocking library. It’s a runtime feature wearing a testing package as a disguise.
评论
?
参与讨论