无法在SpecFlow中执行scenarion outline

时间:2018-05-14 06:56:40

标签: c# specflow gherkin

我有这个测试场景

Scenario Outline: Compare values from the table with references values
    When I opened App
    And I open feature "DC"
    When The value in the '<table>' '<row>' '<column>' must be equal to the '<reference value>'

    Examples: 
    | table      | row | column | reference value|
    | sU         | 2   | 1      | 5.01           |

这个方法

    [When(@"The value in the (.*) (.*) (.*) must be equal to the (.*)")]
    public void GivenSelectValueFromTheTable(string tablename, int row, int column, string expectedValue)
    {
        var valuefromanalysisreporttable = (ISG)Control(tablename);
        var actualValue = valuefromthetable[row, column];
        Assert.AreEqual(expectedValue, actualValue);
    }

它没有用。

它完全可以作为正常的测试场景

Then The value in the table "sU" "4" "1" must be equal to the "5.01"

使用此代码块

 [Then(@"The value in the table ""(.*)"" ""(.*)"" ""(.*)"" must be equal to the ""(.*)""")]
    public void GivenSelectValueFromTheTable(string tablename, int row, int column, string expectedValue)
    {
        var valuefromthetable = (ISG)Control(tablename);
        var actualValue = valuefromanalysisreporttable[row, column];
        Assert.AreEqual(expectedValue, actualValue);
    }

我在占位符和方法内部尝试使用单引号(&#39;)。 我试图在参数之间添加和说明。没有运气。

Message: Assert.Inconclusive failed. No matching step definition found for one or more steps.
using System;
using TechTalk.SpecFlow;

namespace MyNamespace
{
[Binding]
public class StepDefinitions
{
  [When(@"The value in the '(.*)' '(.*)' '(.*)' must be equal to the '(.*)'")]
public void WhenTheValueInTheMustBeEqualToThe(string sgridUpper0, int p1, int p2, Decimal p3)
{
ScenarioContext.Current.Pending();
  }
 }
}

1 个答案:

答案 0 :(得分:1)

尝试从&#34;参考值&#34;中删除空格在表格和用法中。