Further Usage of List Comprehension for Test Coverage
Explore how to use list comprehensions to expand test coverage in Elixir efficiently. Understand the importance of custom failure messages for easier debugging and how to cover both positive and negative cases thoroughly using ExUnit.
We'll cover the following...
We'll cover the following...
Writing custom test failure messages
While list comprehensions allow us to cover more test cases with less test code, they risk obfuscating our errors. If our test fails but we can’t tell which values it was asserting against, we’ll lose time debugging the failure. How would we know which ID we were testing when we had the wrong value of rain in the test we just wrote? Let’s update that assertion to use a custom failure message:
Adding a custom error message with string interpolation (line 6) gives us everything we need to know if ...