-
-
Notifications
You must be signed in to change notification settings - Fork 46
Support async steps #25
Comments
depends on #51 |
Initial tests seem to indicate this may already 'just work'... UPDATE It doesn't - https://twitter.com/dschenkelman/status/415957643354574848 |
Taken by @dschenkelman |
…nd test project XBehave.Features.Net45.csproj. Also updated rakefile.rb and some linked files to work with conditional compilation. This is to setup the ground for issue adamralph#25
…nd test project XBehave.Features.Net45.csproj. Also updated rakefile.rb and some linked files to work with conditional compilation. This is to setup the ground for issue adamralph#25
I have an initial version working at https://github.com/dschenkelman/xbehave.net/tree/issues/25. This is still missing support for Given, Then, When, etc. methods, but I thought I ought to share the approach ASAP to get feedback. I've been going over the XUnit code and the approach they are using for commands related to Task returning methods is implemented by Most of their additional work is related to rethrowing the correct exception, which is something we eventually will want to achieve, but might not be necessary to get done for the initial merge since having async/await support is an improvement in an of itself. Thoughts? |
FYI here is my pull request which adds async support to BDDfy. TestStack/TestStack.BDDfy#32 Feel free to ping me with any questions you guys have while implementing this |
Thanks @dschenkelman. Did you actually push your changes? I see your issues/25 branch sitting on latest master. |
Latest dev, that is. |
It's in now. Forgot to On Mon, Jan 6, 2014 at 3:23 AM, Adam Ralph [email protected] wrote:
|
Great, I'll take a look |
@dschenkelman I've taken a look at your issues/25 branch it looks great. I agree that the exception stuff can come later. One observation (and I realise it's just a work in progress) is that instead of Also, I really like the way you've implemented the timeout in |
@adamralph I like the idea of having Regarding the timeout matter, I'll give. The only case where I'm not sure if it will work is for If we discard |
How would |
The way to support async void is:
Few things, if you want to rethrow the inner exceptions from the AggregateException you can use https://github.com/TestStack/TestStack.BDDfy/pull/32/files#diff-a8d5eed69362f140514897b312913231R78 to preserve the stacktrace before you rethrow. https://github.com/TestStack/TestStack.BDDfy/pull/32/files#diff-a8102fea6ecd77a3994fa2e6dcf9f2d2R1 is the synchronisation context I took from xUnit 2.0 for use in BBDfy Hope that helps :) |
@JakeGinnivan that's awesome info, thank you!. @dschenkelman I'm still struggling to see where we need support for "When bazzing"._(async () => await Bar.Baz()); is there something else we need to support which I'm missing? |
"When bazzed"._(Bar.OnBaz()); //async void OnBaz(object sender, EventArgs e) ? |
@adamralph how do you get syntax highlighing? :P |
Aha! Thank you sir! Syntax highlighting: my code here |
@JakeGinnivan thanks for explaining! you did a much better job than I would have :) @adamralph as Jake said, I think we should support: "When bazzed"._(Bar.OnBaz); //async void OnBaz() |
#25 refactor: change Step to have just abstract Execute()
Most of the work is now done but https://github.com/xbehave/xbehave.net/wiki/Object-disposal does not work currently for async steps. Object disposal uses a thread static collection to collect the disposable objects which are registered within a step body with the This is a tough one. If we cannot use the thread to correlate the objects with a scenario then the only way I can think of is to have overloads of the step extension methods and "Given a DB connection"
._(async c => connection = await GetConnectionAsync("foo").Using(c));
"And another DB connection"
._(c => connection2 = GetConnection("foo").Using(c)); Although the context object isn't needed in the above sync step, it would be confusing and ineffective to attempt to dictate the use of the parameterless Also, if scenario authors are registering disposables object in other threads within a sync step, those registrations are also being lost. If the parameterless It's also worth noting that this problem exists right now in 1.0 for steps which have timeouts attached to them. In these cases, we also invoke the step in a separate thread so objects registered with |
@dschenkelman I've started putting together a solution for the object disposal in https://github.com/adamralph/xbehave.net/tree/25 which introduces the step overloads with the context object which I mentioned above. At the moment I can't think of a better solution. Unless anyone can come up with a better idea, it shouldn't take me long to finish up that work and then we can push out the async feature in 1.1. |
#25 added step overloads with a step context parameter
The .net 4.5 assemblies still need to be added to the NuGet package. |
#25 added .net 4.5 assemblies to nuget package
https://www.nuget.org/packages/Xbehave/1.1.0 Thanks very much for the PRs @dschenkelman and thanks @JakeGinnivan for the valuable input. Look out for your names in the release notes 🏆. |
Thanks Adam, no problem. A pleasure to help. |
Ditto, glad I could help out |
To allow async step definition, e.g.
The text was updated successfully, but these errors were encountered: