3
votes

I have installed specflow. And by default I get this scenario to add two numbers. when I build the solution, i get these errors. "No overload for method 'Given' takes 4 arguments". What is that I am missing here? this is the generated file.

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();
        }

For this scenario:

Feature: SpecFlowFeature1 In order to avoid silly mistakes As a math idiot I want to be told the sum of two numbers

@mytag Scenario: Add two numbers Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen

1
Can you post the code where you get the compilation error? Because the default generated Given: [Given("I have entered (.*) into the calculator")] should compiling fine. - nemesv
It seems you are using an old version of the TechTalk.SpecFlow dll What is the version of your TechTalk.SpecFlow dll? Because it should be 1.9.0. to be able work. Have you installed it with the nuget nuget.org/packages/SpecFlow? - nemesv
I did not install it using commands, but downloaded the dll and added the reference. and its version is 1.8.1.0. Do I have to install anything else? Is it necessary to install nuget package through commands? - Virus

1 Answers

5
votes

It was a problem of techtalk.specflow.dll version. I had 1.8.1 version which I replaced with 1.9.0 and everything worked ! Thank u for ur suggestions