Creating Comprehensive Test Coverage

Learn how to maximize coverage of a test file using setup block and module attributes.

We'll cover the following

We’ve covered some of the very basics of testing and delved into a bit of test theory. To provide solid coverage of a file, we’ll need to build on that knowledge by pulling in some features of Elixir itself, as well as some optional features of ExUnit’s assertions. These skills will help us write maximum test coverage with minimal code and without trade-offs.

Using a setup block

Let’s jump back to where we left our Soggy Waffle test, SoggyWaffle.WeatherAPI.ResponseParserTest. The data we used in our test was hand-coded. That’s a great way to start, but we don’t own the weather API’s original data source. While it’s easy to read the hard-coded data, it’s a significantly parsed-down version of the real data from the weather API.

Get hands-on with 1400+ tech skills courses.