Specflow 没有匹配的步骤定义错误

Specflow no matching step definition error

specflow 的新手。当我 运行 以下时,它在 Then 步骤上一直失败,因为没有定论。我需要做什么才能通过?

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

我 运行 测试时出现以下错误。

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

}
}
}

从 404 中删除 < 和 >。这是我在这里看到的唯一不合逻辑的东西。

另一个解决方案可能是 returns(.*) 之间没有 space。该步骤是不确定的,因为没有任何事情发生。所以你需要在方法中添加一个动作。