无法使用动态对象调用另一个步骤中的步骤定义

Unable to call a step definition within another step with a dynamic object

我正在使用 specflow 编写一些 UI 测试。

场景

Scenario: I can add multiple users
    Given I add the following users
        | FirstName | Surname | Age |
        | Tom       | Jerrum  | 21  |
        | Another   | Person  | 38  |
        | Jimmy     | Jones   | 25  |
    Then I have 3 users displayed

步骤定义

[Given(@"I add the following users")]
public void GivenIAddTheFollowingUsers(IEnumerable<dynamic> people)
{
    foreach(var person in people)
    {
        When(@"I go to the add person page");
        Then(@"I enter the details of the person", person);
        When(@"I save the new person");
        Then(@"I am taken back to the view people page");
    }
}


[Then(@"I enter the details of the person")]
public void ThenIEnterTheDetailsOfThePerson(dynamic person)
{
    AddPersonPage.EnterDetails(person);
}

尝试执行此操作时出现以下错误...

{"The best overloaded method match for 'TechTalk.SpecFlow.Steps.When(string, TechTalk.SpecFlow.Table)' has some invalid arguments"}

尝试调用 Then(@"I enter the details of the person", person); 时出现此错误 由于此错误,无法访问步骤定义中的代码。

我该如何解决这个问题?

解决这个问题的方法是为每个人建立一个 table...

[Given(@"I add the following users")]
public void GivenIAddTheFollowingUsers(IEnumerable<dynamic> people)
{
    foreach(var person in people)
    {
        var header = new [] {"FirstName", "Surname", "Age"};
        var personTable = new Table(header);
        personTable.AddRow(person.FirstName, person.Surname, person.Age);

        When(@"I go to the add person page");
        Then(@"I enter the details of the person", personTable);
        When(@"I save the new person");
        Then(@"I am taken back to the view people page");
    }
}

这似乎可行,但我想避免为每个人建立一个新的 table。