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|
|||setup( context ) do|
||||> Map.put( :setup, :done)|
|||test "setup works", context do|
|||assert context.setup == :done|
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 ...