radish-bdd / radish

Behavior Driven Development tooling for Python. The root from red to green.
https://radish-bdd.github.io
MIT License
181 stars 49 forks source link

Question: Run cleanup tasks on test failure #326

Closed mogthesprog closed 5 years ago

mogthesprog commented 5 years ago

Hi,

so i'm currently trying to add some cleanup steps as after hooks, and i'm having some trouble. It seems that the hooks only get run on success and the only way to run a hook after a failure is to user the after.all decorator.

Is this a bug or desired behaviour? Running some sort of cleanup on failed end-to-end tests seems like it might be a common task. I'm just wondering how best to implement this using radish.

Cheers,

timofurrer commented 5 years ago

Can you provide an example so I can reproduce your issue?

In all my tests the after hooks got executed even though a step failed - so it's really meant to clean up testing resources.

mogthesprog commented 5 years ago

So i think i was actually doing something wrong. I've managed to get my use case working with after.each_scenario.

I was using after.all and it wasn't obvious how i might access the contexts over all scenarios that had run in the test.

really like the framework, btw :)