julien-le-foll
5 years agoNew Contributor
Scenario Outline: parameters are converted to string when the feature is uploaded to cucumberStudio
Hello,
Given the following feature file:
Feature: numeric arguments are lost
Scenario Outline: show loss of numeric types
Given a price of <price>
And the price parameter is an int in step implementation
When the scenario is uploaded to cucumberStudio
Then the price parameter becomes a string
Examples:
| price |
| 30 |
| 40 |
And a java step definition such as:
@Given("a price of {int}")
public void a_price_of(Integer int1) {
//
}
When the feature file is uploaded to cucumberStudio
And the feature file is generated for a given test run
Then the step become "Given a price of "<price>"" (additional quotes around the parameter)
And cucumber expect this definition:
@Given("a price of {String}")
public void a_price_of(String price) {
//
}
How to keep numeric types for step parameters?
Note the feature file generated by hiptest-publisher is:
Feature: numeric arguments are lost
Scenario Outline: show loss of numeric types (<hiptest-uid>)
Given a price of "<price>"
And the price parameter is an int in step implementation
When the scenario is uploaded to cucumberStudio
Then the price parameter becomes a string
Examples:
| price | hiptest-uid |
| 30 | uid:61e34ec9-130f-49de-b8ab-8a007c11d1ce |
| 40 | uid:ecc15e25-fc84-48cc-a79c-1092df7d44ce |
Hello,
Finally your R&D show me a better solution:
- In CucumberStudio set 0 as default value for numeric parameter (add = 0)
- and the following step implementation can be used:
@Given("a price of "(.*)"$") public void a_price_of(double price) { //.... }
The deal is that numeric types can't be used in annotations but it is acceptable