Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cucumber 3.0.0.pre1 - running before hooks multiple times #1098

Closed
westlakem opened this issue Mar 27, 2017 · 5 comments
Closed

Cucumber 3.0.0.pre1 - running before hooks multiple times #1098

westlakem opened this issue Mar 27, 2017 · 5 comments

Comments

@westlakem
Copy link

westlakem commented Mar 27, 2017

Summary

My Before hook runs twice after a failed scenario with the --retry flag

Expected Behavior

The before hook should only run once

Steps to recreate

Create a test suite with a "fail" in the step. In the before hook, open a new Watir::Browser. You will see that 2 browsers get opened after the first "fail")

@danascheider
Copy link
Contributor

Thanks for reporting, @westlakem, I'll have a chance to look into this tomorrow. If you'd be interested in making a pull request we'd be happy to help you put something together - otherwise if we're able to repro we'll fix it but can't guarantee a timeline.

@brasmusson
Copy link
Contributor

brasmusson commented Mar 30, 2017

The unit of execution in Cucumber is what is internally is called a Test Case, and it includes all hooks (before, after, after-step, and around hooks). The semantics of the --retry option, is that after the whole Test Case has executed (including after hooks), if it failed, the whole Test Case (including before hooks etc) is executed again. No state is allowed to leak between the execution of Test Cases, neither between the execution of different Test Cases nor between the execution of a Test Case and the subsequent retry of the same Test Case, therefore it is important that the after hooks are executed before the Test Case is retired, and that the before hooks are executed when the Test Case is retried. This is not an issue, it is the intended behavior.

@westlakem
Copy link
Author

@brasmusson The problem is the --retry flag is running the hooks multiple times in the same test execution. See example execution stack below.

Before hook runs
Test Runs and Fails
After hook runs
Before hook runs
Before hook runs
Test Runs and Fails
After hook runs
After hook runs
Before hook runs
Before hook runs
Before hook runs
Test Runs
After hook runs
After hook runs
After hook runs

@brasmusson
Copy link
Contributor

@westlakem Oh, I misinterpret the issue description. We do not want that.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants