首页 > 解决方案 > 如何从 specflow 的表中将整数添加到场景和功能文件中?为什么我会收到棕褐色错误

问题描述

当我将方案更改为使用表中的整数时,出现以下错误:参数计数不匹配!.,我所做的只是在工作正常的场景中将条件中的数字从 200 更改,但是当我使用时,请参阅代码,出现错误,这里:

Scenario: When I submit my request to an API
    Given Given a valid input is used
    When the specific request data is meets certain criteria
    Then the status code for this test should be <ExpectedResult>
Examples:
    | ExpectedResult|
    | 200|

这一步非常标准,但错误在于上面的功能文件:

        [Then(@"the status code for this test should be (.*)")]
        public void ThenTheStatusForThisTestCodeShouldBe(int p0)
        {
            //Do I get the expected status codes
            Assert.AreEqual(p0, 200);
        }

我错过了什么吗?

标签: c#apispecflow

解决方案


为了使用示例表,您必须将其指定为Scenario Outline

Scenario Outline: When I submit my request to an API
    Given ...
    When ...
    Then ...

Examples:
    | ExpectedResult |
    | 200            |

推荐阅读