I want to write a regular expression for input box validation with respect to Gherkin syntax.The valid example inputs are like this Ex: Given I enter 'www.google.com' And enter keyword 'new york'.
Summary
A valid regular expression fails to match with Cucumber JVM 4.2.6
Expected Behavior
When a step definition has a regular expression using d+ (more than one digit) and no anchors, it should match.
Current Behavior
![Define Define](/uploads/1/2/3/9/123900935/501378461.jpg)
Crash
Possible Solution
Not sure
Steps to Reproduce (for bugs)
0 anchors1 (PASS)
0 anchors2 (PASS)
cucumber.runtime.CucumberException: Step [(d+) anchors3] is defined with 1 parameters at 'foo.Steps.anchors(Integer) in file:/.../classes/'.
However, the gherkin step has 0 arguments.
Step text: 0 anchors3
at cucumber.runner.PickleStepDefinitionMatch.arityMismatch(PickleStepDefinitionMatch.java:84)
at cucumber.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:36)
at cucumber.runner.TestStep.executeStep(TestStep.java:63)
at cucumber.runner.TestStep.run(TestStep.java:49)
at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:43)
at cucumber.runner.TestCase.run(TestCase.java:45)
at cucumber.runner.Runner.runPickle(Runner.java:40)
at cucumber.runtime.Runtime$1.run(Runtime.java:82)
at cucumber.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:217)
at cucumber.runtime.Runtime.run(Runtime.java:79)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:8)
0 anchors2 (PASS)
cucumber.runtime.CucumberException: Step [(d+) anchors3] is defined with 1 parameters at 'foo.Steps.anchors(Integer) in file:/.../classes/'.
However, the gherkin step has 0 arguments.
Step text: 0 anchors3
at cucumber.runner.PickleStepDefinitionMatch.arityMismatch(PickleStepDefinitionMatch.java:84)
at cucumber.runner.PickleStepDefinitionMatch.runStep(PickleStepDefinitionMatch.java:36)
at cucumber.runner.TestStep.executeStep(TestStep.java:63)
at cucumber.runner.TestStep.run(TestStep.java:49)
at cucumber.runner.PickleStepTestStep.run(PickleStepTestStep.java:43)
at cucumber.runner.TestCase.run(TestCase.java:45)
at cucumber.runner.Runner.runPickle(Runner.java:40)
at cucumber.runtime.Runtime$1.run(Runtime.java:82)
at cucumber.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:217)
at cucumber.runtime.Runtime.run(Runtime.java:79)
at cucumber.api.cli.Main.run(Main.java:26)
at cucumber.api.cli.Main.main(Main.java:8)
Context & Motivation
The lack of matches hurt me while upgrading from Cucumber 2.x to 4.2.6, I had to redo a number of regular expressions, by adding anchors.
Your Environment
- Version used: 4.2.6
- Operating System and version: Linux, Arch.
- Link to your project: n/a
I am unable to execute the below Cucumber scenario due to error in my step definition file for my when step
Regular expression for Date and MonthYear have some problem. I have added my Cucumber Scenario and snippet of my step definition
Step Definition
vishalmgadavishalmgada
1 Answer
You need to use
int
for the date and the regular expression from monthYear will not pass the month part.GrasshopperGrasshopper