Composing Within Tests
Let’s start writing helper functions that'll help us in testing our quizzes.
We'll cover the following
The Quiz
module
The most complex module is Quiz
, because it’s the module that holds state as we progress through a test. It needs to perform the following tasks:
-
Generate questions from templates.
-
Cycle through templates.
-
Track success.
-
Finish when success is achieved.
We’ve put it off as long as we can, but we finally need to face it. We’ll tackle it with our setups and by composing through our token, the Quiz
.
Constructing our quiz
We’ll create a new file, /test/quiz_test.exs
, to construct our quiz. We start with the typical ceremony, the module plus the two use directives, like this:
Get hands-on with 1200+ tech skills courses.