Skip to content

How to run code when any scenario fails? #245

Answered by tyranron
ms-ati asked this question in Q&A
Discussion options

You must be logged in to vote

@ms-ati you have two options:

  1. Use .after() hook. It runs even if the scenario has failed, however is enabled for all executed scenarios, which may not be convenient.
  2. Use custom Drop implementations. This can be more tedious in terms of writing code, but allows any desired level of granularity.

In particular -- I'd like, optionally, to have a per-Scenario temporary directory

World has a lifespan of a scenario. So you can just put it into your World as Option<TempDir>.

not be deleted when the test fails, so that it is possible for the user to examine the contents of the temp dir.

So you should set some sort of flag at the last step of the scenario in your World. And if it's not set, t…

Replies: 3 comments 8 replies

Comment options

You must be logged in to vote
7 replies
@ilslv
Comment options

@tyranron
Comment options

@ilslv
Comment options

@tyranron
Comment options

@ms-ati
Comment options

Answer selected by tyranron
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@tyranron
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested k::api Related to API (application interface)
3 participants
Converted from issue

This discussion was converted from issue #244 on November 15, 2022 11:04.