July 2017
Intermediate to advanced
284 pages
6h 45m
English
We can do better, though. We think the setup block should run an experiment, and each test block should run measurements. Combining setup code with test code makes it hard to isolate single-purpose code. The experiments and measurement concerns can become too entangled.
Let’s rewrite that:
| | defmodule AppTest do |
| | use ExUnit.Case |
| | |
| | setup( context ) do |
| | context |
| | |> Map.put( :setup, :done) |
| | end |
| | |
| | test "setup works", context do |
| | assert context.setup == :done |
| | end |
| | end |
That’s a little better. We have a setup block that can run an experiment and test code that can run measurement. That’s a potential improvement, but since there’s typically only a single setup, the improvements ...
Read now
Unlock full access