简体   繁体   中英

How to add integers to scenario and feature files from a table in specflow? Why do I get tan error

When I change my scenario to use integers from the table I get the following error: Parameter count mismatch. ,, all I have done is change the number in condition from 200 in the scenario which works fine but when I use, see code the error appears: here:

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|

The step of this is pretty standard but the error lies in the feature file above:

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

Am I missing something?

In order to use an Examples table, you must specify this as a Scenario Outline :

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

Examples:
    | ExpectedResult |
    | 200            |

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM