We are trying to get the next step in the script to break the test if a failure occurs in the DoAyncStuff() method:
[Given(@"There is something")] public async Task GivenSomething() { await DoStuff(); } private async Task DoStuff() { await Task.Run(() => Thread.Sleep(1000)); throw new ApplicationException("Boom"); }
But actually it makes the green move happy until you use .Wait() or .Result :
[Given(@"There is something")] public void GivenSomething() { DoStuff().Wait(); }
The problem is that the generated NUnit specification looks like this:
public virtual void SomethingAsync() { ... testRunner.Given("There is something", ...); ... }
which seems to work with the following code:
public virtual async Task SomethingAsync() { ... await this.ScenarioSetup(scenarioInfo); ... }
The above code has been manually edited by an automatically generated file, so I'm really looking for a way to create the following code automatically.
The documentation is apparently the only option available for the asynchronous API, but in fact for Silverlight, and as I understand it, uses some kind of API, while we would prefer to use the native C # wait keyword.
Is there a way to handle async/await natively these are SpecFlow steps?
source share