Our First Test

Learn how to use ExUnit by writing our first test.

From the beginning, Elixir was developed with ExUnit, Elixir’s testing framework, as part of the core library. As a result, most of the test tooling we’ve come to utilize in our production applications is straight out of the Elixir core. This means that if we have Elixir and are familiar with what’s available, we can write effective tests without bringing in other libraries.

Write our first test

Let’s write our first test in our rain alert app, Soggy Waffle. Soggy Waffle makes calls to an API and gets data back from it. It then standardizes that data according to its terms and data structures for the rest of the application. While those calls to the API aren’t something we’ll focus on in the course, the response transformation is an excellent example of code that can be tested in isolation. Let’s take a look at the code we’ll be testing.

Note: If you want to code along with the examples, you should do so inside the provided Soggy Waffle application, adding test files ...