I want to implement case insensitivity in my gherkin for my project such that the following works:
Scenario: test case insensitive gherkin
Given perform get request "http://testurl:3000/topics"
Given perform GET request "http://testurl:3000/topics"
Given perform GET REQUEST "http://testurl:3000/topics"
I wrote the following step definition (for the above gherkin steps) with the following regex which removed the undefined step references, and it seemed like I found the solution:
@Given("(?i)^perform get request \"([^\"]*)\"$")
public void performGetRequest(String url) throws Throwable {
//Implementation
}
Basically, I prefixed (?i) regex prior to regex start which resolved all the gherkin steps. However, when I executed the test, I got the following error:
java.util.NoSuchElementException
at io.cucumber.cucumberexpressions.TreeRegexp$IntRange.next(TreeRegexp.java:99)
at io.cucumber.cucumberexpressions.TreeRegexp$IntRange.next(TreeRegexp.java:82)
at io.cucumber.cucumberexpressions.GroupBuilder.build(GroupBuilder.java:18)
at io.cucumber.cucumberexpressions.GroupBuilder.build(GroupBuilder.java:21)
at io.cucumber.cucumberexpressions.TreeRegexp.match(TreeRegexp.java:75)
at io.cucumber.cucumberexpressions.Argument.build(Argument.java:12)
at io.cucumber.cucumberexpressions.RegularExpression.match(RegularExpression.java:54)
at io.cucumber.stepexpression.StepExpression.match(StepExpression.java:22)
at io.cucumber.stepexpression.ExpressionArgumentMatcher.argumentsFrom(ExpressionArgumentMatcher.java:21)
at cucumber.runtime.java.JavaStepDefinition.matchedArguments(JavaStepDefinition.java:58)
at cucumber.runner.Glue.stepDefinitionMatches(Glue.java:104)
at cucumber.runner.Glue.stepDefinitionMatch(Glue.java:82)
at cucumber.runner.Runner.addTestStepsForPickleSteps(Runner.java:64)
at cucumber.runner.Runner.createTestCaseForPickle(Runner.java:54)
at cucumber.runner.Runner.runPickle(Runner.java:39)
at cucumber.api.testng.TestNGCucumberRunner.runScenario(TestNGCucumberRunner.java:68)
at com.sabre.cucumber.runner.TestRunner.scenario(TestRunner.java:121)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
at org.testng.internal.Invoker.invokeMethod(Invoker.java:583)
at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:719)
at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:71)
at org.testng.internal.TestMethodWithDataProviderMethodWorker.call(TestMethodWithDataProviderMethodWorker.java:14)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
I am using the following maven dependencies - cucumber-java, cucumber-testng - version 4.2.0 and java 8. I believe cucumber-expression is not liking something about my regex.
Can somebody suggest how to achieve case insensitive gherkin using cucumber-expression or regular-expression? Let me know if any other information is needed.
Thanks,
Anukul