erikedin / Behavior.jl

Tool for Behavior Driven Development in Julia
Other
25 stars 3 forks source link

Add support for beforeall and afterall #54

Open tk3369 opened 3 years ago

tk3369 commented 3 years ago

Add @beforeall and @afaterall macros such that they run immediately before and after execution. Note that there's a similar issue #17 for steps. It may be good to implement these at the same time.

For reference, Python's behave package documentation about this can be found at https://behave.readthedocs.io/en/stable/tutorial.html#environmental-controls

This enhancement is required to support Grakn client. See master issue #44.

erikedin commented 3 years ago

When you have time, have a look at the documentation for this at

https://github.com/erikedin/Behavior.jl/blob/master/docs/src/usage.md

It's currently at the bottom. You'll basically be able to define hooks like

@beforeall() do
    # Some code here
end

@afterall() do
    # Some code here
end

Does this work for you? If it does, you can close the issue, else we'll keep it open and work on it.

Since these hooks take no arguments, since no context object is available yet, they can only create global resources. Is that a problem for you?

FrankUrbach commented 3 years ago

It would be great, if we could have a context at least for @afterall so we can use this to delete all databases or something else.
If all tests are green it isn't a problem. But most of the time you work on tests and it crashes or you haven't all tests made and the the work will not be finished. Sure, I could made a separate client or session and make what I want. But this implies two places where I have to determine the server and the port.