Async/Await support for Specflow Steps => I would like to use SpecFlow with the Async Await Features of C#, windows phone 8, SpecFlow with MSTest can execute Code using async / await but doesn't wait for the Results.
I've changed BindingInvoker.cs and upgraded to .NET 4, in order to support async tasks, and receiving now IOC is not initialized errors.
https://github.com/robfe/SpecFlow/commit/507368327341e71b2f5e2a4a1b7757e0f4fb809d
It's permissible for an async method to return void, but it's not recommended because it's very difficult to consume (or test) an async void method. The task instance returned from an async method is managed by the state machine.
In general, you should make a method asynchronous if the synchronous method blocks the ASP.NET request thread while doing no work. By making the call asynchronous, the ASP.NET request thread is not blocked doing no work while it waits for the web service request to complete.
For methods other than event handlers that don't return a value, you should return a Task instead, because an async method that returns void can't be awaited. Any caller of such a method must continue to completion without waiting for the called async method to finish.
Yes. SpecFlow does support async steps
See https://docs.specflow.org/projects/specflow/en/latest/Bindings/Asynchronous-Bindings.html
For example:
[When(@"I want to get the web page '(.*)'")]
public async Task WhenIWantToGetTheWebPage(string url)
{
await _webDriver.HttpClientGet(url);
}
It will not continue to the next step until this step was finished but it will release the thread to perform other tests
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With