我们正在试图获得以下scenrio一步打破测试的情况下,故障发生DoAyncStuff()
方法中:Specflow用的await步骤异步API
[Given(@"There is something")]
public async Task GivenSomething()
{
await DoStuff();
}
private async Task DoStuff()
{
await Task.Run(() => Thread.Sleep(1000));
throw new ApplicationException("Boom");
}
但它实际上使一个快乐的绿色运行,直到你使用.Wait()
或.Result
:
[Given(@"There is something")]
public void GivenSomething()
{
DoStuff().Wait();
}
这个问题似乎是在NUnit的生成规格,看起来像这样:
public virtual void SomethingAsync()
{
...
testRunner.Given("There is something", ...);
...
}
这似乎与下面的代码工作:
public virtual async Task SomethingAsync()
{
...
await this.ScenarioSetup(scenarioInfo);
...
}
上面的代码是手动编辑自动生成的文件,所以我实际上是寻找一种方法来自动生成下面的代码。
The documentation似乎是可供asyncronous API唯一的选择,但它实际上是对Silverlight和,据我了解使用某种类型的API,而我们会preffer使用本机C#等待关键字。
有没有办法处理本机async/await
是SpecFlow的步骤?
看看[this](https://github.com/techtalk/SpecFlow/pull/647)发布 –