Cucumber Scenario : giving an empty String as value of parameter in a scenario step
11,178
You can change it to ''
but then since (.+)
will match at least one of anything, using ''
will not match the step.
Try using (.*)
in your step definition which will match an empty string i.e. ''
Author by
blaiso
Updated on June 04, 2022Comments
-
blaiso almost 2 years
I have a step implemented like this:
@When("I add an attribute named '(.+)' with unit '(.+)' to the item named '(.+)'") public void addAttributeToAndItem(String attributeName, String unitName, String itemName){ ..... }
in my Cucumber Scenario, i would like to add and attribute not having a unit, so the value of "unit name" should be and empty String. how can I specify this empty String in to my Scenario step.
I tried this one:
Scenario: add attribute to an item When I add an attribute named 'Color' with unit ' ' to the item named ' Car'
but it does not work. The ' ' is always seem as a value (a space) and not an empty string. please can somebody help me?