Search code examples
javacucumbercucumber-junit

How do I convert a parameter in an example table to an integer in a Cucumber feature?


If I have a feature that looks like this:

Feature: My feature
  Scenario Outline: My scenario outline.
    Given foo
    When bar
    Then I get the status code "<Status Code>".

  Examples:
   | StatusCode |
   |        200 |

and a step definition like this:

@Then("I get the status code {int}.")

Cucumber complains and says that the step is undefined, because it's expecting the type to be {string}. Is there a way to specify the type in the feature or the example table? I've looked into the TypeRegistryConfiguration but I can't work out how to make it work with feature files.


Solution

  • Removing the quotes around <StatusCode> as suggested by @M.P.Korstanje fixed it. After doing that, Cucumber then recognised it as an integer and picked up the step defintion.