Open raindrift opened 8 years ago
Hey @raindrift!
Mamba provides a before.all hook on every suite. Do you refer to all suites or with this hook is enough?
Thanks!
I know about the hooks. What I'm wondering is, can I have a before.all or a before.each on the entire test suite?
For example, let's say I have a spec/
directory with six spec files. Right now, I'm doing the following in each file:
from spec.helper import *
from myproject import mymodule
with description('mymodule'):
with before.each:
setup(self)
Then, spec.helper
implements a setup()
function that sets up a connection to my test database, clears the db, etc.
I'd love to remove that chunk of boilerplate from all my tests, though. It'd be great if there was some global configuration where I could specify these things. It'd make the test files cleaner, and reduce the chance that I'll forget to call it.
+1
Oookey, I see :)
It's something like before/after hooks in configuration, like RSpec ones: https://relishapp.com/rspec/rspec-core/v/3-7/docs/hooks/before-and-after-hooks#define-%60before%60-and-%60after%60-blocks-in-configuration
And when we have tagging support, i thing this idea would be useful too: https://relishapp.com/rspec/rspec-core/v/3-7/docs/hooks/when-first-matching-example-defined-hook
Thanks for the idea, I would consider it for 1.0 release :)
Thanks for considering this @nestorsalceda
@nestorsalceda will this feature be added anytime soon? Considering migrating from pytest > mamba, but having a global fixture (defining it only once) that runs for every single "it" block in my entire testing directory is essential.
Yes, I think is easy to implement. I have some doubts about how to share state between the specs, but I think it can be done easily.
I'm going to target it to next week release :)
It'd be wonderful to be able to define a
before.each
for the entire suite. This would allow things like ensuring that the database is always cleared between examples. As it is, I have to do the global test setup once per file.With RSpec, which seems to be what mamba is modeled on, you can put
before(:each)
andbefore(:all)
in the global rspec configuration.