You then write a test case:
@test isapprox(golden_ratio, 1.618, atol=1e-3)
@test is_prime(37)
and hide the code. This will display a pretty block with colors to show the result.
You don't need special functions for some extra behavior:
if isapprox(golden_ratio, -0.618, atol=1e-3)
md"You found the negative golden ration! We want the positive value."
end
Maybe you can give extra options about exercises:
optional(@test isapprox(golden_ratio, 1.618, atol=1e-3))
(Julia docs recommend that you only use macros when necessary, I agree)
It would be cool if you can make some tests public (they will run reactively while the student works on the exercise), and some hidden (they do not appear in the student's notebook, they are only used by the teacher for autograding).
For example, a public test:
@test is_prime(37)