Using SafeTestsets
is a best practice for testing. This kind of TestSet
keeps tests from interfering with each other, so I couldn’t define a function setup_test()
outside of @safetestset
and use it inside the TestSet
. I figured out a way to do it and wonder whether others are using different methods?
If I make a named module in the testing code, like module TestSetup
, then I can refer to it within a SafeTestSet
with using ..TestSetup
. This works because each SafeTestset
implicitly places its code within a module to guard it from other TestSets
.
The other rule of the game is that TestSets
can be nested, as long as SafeTestset
is at the bottom of the hierarchy. At this point, I’m treating SafeTestset
the way I’d treat each unit test in Python, R, or C++ and treating @test
as a testing assertion.
Hope All Is Well - Drew