J OpenDock
J OpenDock

Reputation: 59

Specflow no matching step definition error

New to specflow. When i run the below it keeps failing on the Then step as inconclusive. What do i need to do to make this pass?

       public virtual void SearchAPICalledWithMissingParameter()
        {
            TechTalk.SpecFlow.ScenarioInfo scenarioInfo = new TechTalk.SpecFlow.ScenarioInfo("Search API called with missing parameter", new string[] {
                        "search"});
#line 8
this.ScenarioSetup(scenarioInfo);
#line 9
 testRunner.Given("I call Search API without parameter", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Given ");
#line 10
 testRunner.When("I get the response back from API", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "When ");
#line 11
 testRunner.Then("API returns <404>", ((string)(null)), ((TechTalk.SpecFlow.Table)(null)), "Then ");
#line hidden
            this.ScenarioCleanup();
        }
    }
}

I get the following error when i run the test.

No matching step definition found for one or more steps.
Using system:
Using TechTalk.SpecFlow;


namespace Mynamespace
{
[Binding]
public class StepDefinitions 
{
[Then(@"API returns(.*)")]
public void ThenAPIReturns(string p0)
{
ScenarioContext.Current.Pending();

}
}
}

Upvotes: 1

Views: 2446

Answers (1)

Anand
Anand

Reputation: 1939

Remove the < and > from the 404. Thats the only illogical thing I can see here.

Another solution could be that there is no space between returns(.*). The step is inconclusive because there is nothing happening. So you need to add an action in the method.

Upvotes: 1

Related Questions