在VisualStudio2010Pro上,我在同一个类库中有SpecFlow和NUnit (分别来自NuGet )。App.Config是:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
</configSections>
<specFlow>
<!-- For additional details on SpecFlow configuration options see https://github.com/techtalk/SpecFlow/wiki/Configuration -->
<unitTestProvider name="NUnit" />
</specFlow>
</configuration>我有一个默认的模板特性文件,它正确地使用了NUnit,如下所示:
[NUnit.Framework.TestAttribute()]
[NUnit.Framework.DescriptionAttribute("Add two numbers")]
[NUnit.Framework.CategoryAttribute("mytag")]
public virtual void AddTwoNumbers()
{
TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Add two numbers", new string[] {
"mytag"});
#line 7
this.ScenarioSetup(scenarioInfo);
#line 8
testRunner.Given("I have entered 50 into the calculator");
#line 9
testRunner.And("I have entered 70 into the calculator");
#line 10
testRunner.When("I press add");
#line 11
testRunner.Then("the result should be 120 on the screen");
#line hidden
this.ScenarioCleanup();
}工具->Options->SpecFlow->TestRunnerTool设置为auto,但我看到下拉列表中没有列出NUnit。
当我右键单击这个特性文件并尝试运行这些场景(默认的计算器场景和模板中的两个数字)时,弹出对话框会说“找不到匹配的测试运行程序。请在”Tools/Options/SpecFlow“中指定测试运行程序工具。
,我怎么才能让NUnit在那个下拉列表中?或者我还能做些什么让SpecFlow运行这个特性文件呢?
NUnit.Framework.dll运行时版本v2.0.50727 NUnit.Framework.dll版本2.6.0.12051
TechTalk.SpecFlow.dll运行时版本2.0.50727 TechTalk.SpecFlow.dll版本1.8.1.0
发布于 2013-05-11 23:00:28
SpecFlow.org站点(http://www.specflow.org/specflownew/ProjectSetupGuide.html)上的示例使用SpecRun (http://nuget.org/packages/SpecRun.NUnit)。SpecRun是将NUnit与Visual集成的一种方法,因此您可以通过右键单击执行SpecFlow/NUnit测试。SpecRun不是一个免费的工具。您不会在工具/选项/SpecFlow下拉列表中看到NUnit,但是如果您通过NuGet安装了该工具,您将看到SpecRun。
如果您有ReSharper,则在右键单击运行SpecFlow测试时也支持这一点。
http://www.youtube.com/watch?v=c2ge90BWeI0
发布于 2013-12-07 16:29:38
在学习做BDD的时候,我看到了这篇对我非常有用的博客文章,它解释了每一个方面,从设置到使用SpecFlow/NUnit运行测试。
.Net中使用SpecFlow、Selenium和NUnit的行为驱动开发
至于SpecFlow二进制文件,它们并不容易找到。由于我更喜欢这样做,我对SpecFlow网站进行了更深入的挖掘,以找到这个提供二进制文件的页面:高级项目设置。
https://stackoverflow.com/questions/9892490
复制相似问题