Isolate the Proctor’s Boundary Concerns

In many ways, our proctor is the biggest testing challenge in this book. We have a scheduler that depends on concepts of both mutability and time, ideas that are generally kryptonite for tests.

The scheduler has three events: schedule, start quiz, and stop quiz. Each of these ideas is important. Our tests could wait, using sleeps, as our quizzes cycle through their respective states, but that strategy would make our tests both fragile and slow.

Sleeps in tests are inherently bad. Wait too long and your tests are slow; don’t wait long enough and your tests won’t be consistent. To prevent race conditions and timing dependent code, we’ll need to find a better approach.

Here’s our plan, then. Let’s modify ...

Get Designing Elixir Systems With OTP now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.