You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Often a set of tests has some common setup and teardown code you want to run for each test. It would be great to be able to do something like:
module TestMyModule
@setup begin
obj = SomeObj()
obj.times_called = 0
end
facts() do
# setup block runs here
run_my_func(obj)
@fact obj.times_called = 1
# teardown block runs here
end
end # module TestMyModule
I think that it would make sense that @setup block defined at the module scope would be run for each facts block, and @setup defined inside a facts block would apply to each context
The text was updated successfully, but these errors were encountered:
I should also note that it feels a little sketchy for the @setup and @teardown blocks to just get pasted into the fact body. One option would be to have the testing do block take an argument that has any testing environment created by @setup
I'm going to tag this one as "up for grabs" because I feel a lot of macro magics are required to make this work well, and a similar effect can be achieved with just good old-fashioned functions.
A question: have you considered doing the setup/teardown in pytest fixtures style.? I am using pytest a lot now, and after a moment of getting used to I grew very fond of this approach.
BTW, do you have any knowledge of any testing framework for Julia that would try to mimic pytest's idea?
Often a set of tests has some common setup and teardown code you want to run for each test. It would be great to be able to do something like:
I think that it would make sense that
@setup
block defined at the module scope would be run for eachfacts
block, and@setup
defined inside afacts
block would apply to eachcontext
The text was updated successfully, but these errors were encountered: