Skip to content
This repository was archived by the owner on Mar 14, 2026. It is now read-only.
This repository was archived by the owner on Mar 14, 2026. It is now read-only.

@setup and @teardown blocks #20

Description

@ssfrr

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions