Grokking Concurrency in Go
Vote

0% completed

​

Deterministic Tests with synctest

One test function on this page checks that a call gives up after 2 seconds when the server never answers. The same function runs twice in one go test command. The first time it runs as an ordinary test, and it takes 2.00 seconds of real time. The second time it runs inside synctest.Test, and it finishes in less than a millisecond, although its own clock reports that exactly 2 seconds passed.

Both runs pass, and both check the same behavior. The difference is the clock. The first run waits for real time to pass, so every timeout in the suite adds its full length to the run

.....

.....

.....

Like the course? Get enrolled and start learning!

Reading Progress

0%


Vote for new content