Compose Within Tests
The most complex module is Quiz because that’s the module that holds state as we progress through a test. It needs to generate questions from templates, cycle through templates, track mastery, and finish when mastery is complete. We’ve put it off as long as we can. We need to slay this beast. We’ll attack it with our setups and by composing through our token, the Quiz.
Crack open test/quiz_test.exs to construct our quiz. Start with the typical ceremony, the module plus the two use directives, like this:
| defmodule QuizTest do |
| use ExUnit.Case |
| use QuizBuilders |
Next, we’ll need helper functions, one that handles random question generation and one to build a convenient shortcut to return the ...
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.