December 2019
Intermediate to advanced
248 pages
5h 34m
English
You’ve just seen the first type of setup function, fixtures. In this section, we’ll cover the next kind of reusable setup function, ExUnit’s named setup feature. To understand how it works, let’s take a more detailed look at the flow of a typical ExUnit testcase.
In version 1.3 of Elixir, the ExUnit.Case module added a describe block. Tests within a block could share common setup code. When you specified a block of tests within a describe, you could also specify the names of one or more functions to create common setup data. Here’s how that would look, in our test layer:

You can see how tests with describe work. ...
Read now
Unlock full access