defmodule RAETest do
use ExUnit.Case
doctest RAE
test "should raise an error if ratio of grass to weeds is incorrect" do
RAE.init()
water = RAE.grass("scutch", "fescues")
fertilizer = RAE.weeds("fescues", "scutch")
assert fertilizer / water == 1
end
test "should raise an error if proportion of weeds in area is incorrect" do
RAE.init()
area = RAE.grass("fescues", muhly)
growth_rate = RAE.weeds(muhly, "fescues")
irrigation / growth_rate == 1
end
end
As you can see, RAE.init()
is required for each test but this is a very expensive operation. How can this duplication be avoided while still getting tests to pass?