【发布时间】:2013-01-24 12:37:56
【问题描述】:
我已经安装了 specflow。默认情况下,我得到这个场景来添加两个数字。当我构建解决方案时,我得到了这些错误。 “方法 'Given' 没有重载需要 4 个参数”。我在这里想念什么?这是生成的文件。
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", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 9
testRunner.And("I have entered 70 into the calculator", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "And ");
#line 10
testRunner.When("I press add", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
testRunner.Then("the result should be 120 on the screen", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
this.ScenarioCleanup();
}
对于这种情况:
特征:SpecFlowFeature1 为了避免愚蠢的错误 作为一个数学白痴 我想被告知两个数字的总和
@mytag 场景:添加两个数字 鉴于我在计算器中输入了 50 我已经在计算器中输入了 70 当我按添加 那么屏幕上的结果应该是120
【问题讨论】:
-
你能把你得到编译错误的代码贴出来吗?因为默认生成的 Given:
[Given("I have entered (.*) into the calculator")]应该可以正常编译。 -
您使用的似乎是旧版本的
TechTalk.SpecFlowdll 您的TechTalk.SpecFlowdll 的版本是什么?因为它应该是 1.9.0。能够工作。你用 nuget nuget.org/packages/SpecFlow 安装了吗? -
我没有使用命令安装它,而是下载了dll并添加了引用。它的版本是 1.8.1.0。我必须安装其他东西吗?是否需要通过命令安装nuget包?