The Final Test for Our Quizzes
Let’s learn to write setup code and then test our quiz one last time.
Once the additional infrastructure of the scheduling notification is in place, our tests will be easier to write.
Let’s dive right in. We’ll write this in /test/proctor_test.exs
:
defmodule ProctorTest douse ExUnit.Casealias Mastery.Examples.Mathalias Mastery.Boundary.QuizSession@moduletag capture_log: true
We do the typical setup ceremony with one addition. With the module attribute @capture_log
, we turn on the logging capture to avoid adding noisy logging to our test cases.
The rest of this test case will deal with time. Boundaries are powerful, but all of that power has a cost—the ceremony of dealing with time. This test exists specifically to walk our code through its entire lifecycle, step by step. We’ll do all of this work in a single test to keep things simple to read and maintain in the future.
Our setup to start the quiz
The first step is to start up the quiz, like ...