Composing Within Tests
Explore how to effectively compose tests for Elixir modules that manage state, like the Quiz module. Learn to use helper functions to generate questions, cycle templates, and track progress, while integrating assertions seamlessly within test pipelines to verify mastery and functionality.
We'll cover the following...
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 ...