【发布时间】:2012-03-27 15:19:25
【问题描述】:
在 Visual Studio 2010 Pro 上,我在同一个类库中有来自 NuGet 的 SpecFlow 和 NUnit(分别)。 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();
}
Tools->Options->SpecFlow->TestRunnerTool 设置为 auto,但我看到 NUnit 没有在下拉列表中列出。
当我右键单击功能文件并尝试运行场景(关于计算器的默认场景和模板中的两个数字)时,弹出对话框显示“找不到匹配的测试运行器。请在'中指定测试运行器工具”工具/选项/SpecFlow'
如何在该下拉菜单中获取 NUnit?或者我还能做些什么来让 SpecFlow 运行功能文件?
NUnit.Framework.dll 运行时版本 v 2.0.50727 NUnit.Framework.dll 版本 2.6.0.12051
TechTalk.SpecFlow.dll 运行时版本 2.0.50727 TechTalk.SpecFlow.dll 版本 1.8.1.0
【问题讨论】:
-
所以项目(两个 dll)构建。我没有在 Visual Studio 中使用右键单击运行场景,而是打开了 NUnit 并从那里运行测试。这行得通。
标签: testing nunit config specflow