Skip to content
This repository has been archived by the owner on Jun 12, 2021. It is now read-only.

Execute each step immediately after it is defined #362

Open
adamralph opened this issue Dec 23, 2016 · 6 comments
Open

Execute each step immediately after it is defined #362

adamralph opened this issue Dec 23, 2016 · 6 comments
Labels
breaking This change could break current consumers enhancement New feature or request on-hold This can't be done yet
Milestone

Comments

@adamralph
Copy link
Owner

adamralph commented Dec 23, 2016

Spun off from #361 raised by @epitka

The wiki page for reusing steps previously described an alternative method of the form:

"Given..."
    .x(() => ...);
"When..."
    .x() => ...);
Then.CoolOutcomes(result);

This does not work in 2.x, since the steps are defined while the scenario method is running, and executed afterwards. IIRC this did work in 1.x since each step was executed immediately after being defined, but this changed to deferred execution in 2.0.

I think this is a breaking change so will require a version bump to 3.0, but I'll have to consider that a little more before being sure.

@adamralph adamralph added breaking This change could break current consumers enhancement New feature or request labels Dec 23, 2016
@adamralph adamralph changed the title Execute a step immediately after it is defined Execute each step immediately after it is defined Dec 23, 2016
@enzian
Copy link
Contributor

enzian commented Dec 29, 2016

What was the original incentive for moving to deferred execution? (I think I'd be able to do without it!)

@adamralph
Copy link
Owner Author

@enzian IIRC I didn't make a conscious decision to change to deferred execution.

xbehave 2.0 was a complete rewrite from scratch (due to the complete rewrite from scratch of xunit 2.0). The xbehave 2.0 acceptance tests were carried over from 1.x and immediate execution was not an enforced invariant in 1.x.

Perhaps immediate execution was something that resulted naturally from the xunit 1.x extensibility model and deferred execution from the xunit 2.0 model. I'm not entirely sure whether immediate execution is even possible with xunit 2.0.

@ursenzler
Copy link
Contributor

If possible, I'd prefer immediate execution because we had to introduce some dummy steps in our tests to compensate for deferred execution. Also, it's something that people I teach about xBehave struggle with, in the beginning.

@adamralph
Copy link
Owner Author

@ursenzler that's interesting. Could you provide an example please?

@adamralph adamralph added the P2 label Nov 1, 2017
@ursenzler
Copy link
Contributor

@adamralph I'll have to show you in our code, I struggle to explain it without context.

@adamralph
Copy link
Owner Author

@ursenzler I can only imagine that you must have a need to execute specific code outside step delegates. If everything is inside, then everything is deferred and you should not have any problems.

The basic premise of xbehave is that everything should be inside step delegates. If something is outside, then yes, I can imagine that the deferred execution could be problematic. If indeed you do have a need to execute code outside steps, I'd very much like to know more about it, so that we can investigate what needs to be done to avoid having to do that.

Incidentally, I've had it on my to-do list for some time to include an analyzer in xbehave that warns when a scenario contains anything outside a step delegate.

@adamralph adamralph added this to the 3.0.0 milestone Jun 1, 2018
@adamralph adamralph added P1 and removed P2 labels Sep 22, 2018
@adamralph adamralph removed the P1 label Oct 2, 2018
@adamralph adamralph modified the milestones: 2.4.1, 3.0.0 Oct 20, 2018
@adamralph adamralph added the on-hold This can't be done yet label Oct 28, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking This change could break current consumers enhancement New feature or request on-hold This can't be done yet
Projects
None yet
Development

No branches or pull requests

3 participants