[Cucumber-JVM]: Case insensitive gherkin not working

380 views
Skip to first unread message

Anukul Singhal

unread,
Jan 11, 2020, 9:26:00 PM1/11/20
to Cukes
Hi,

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

aslak hellesoy

unread,
Jan 12, 2020, 3:50:36 PM1/12/20
to Cucumber Users
Hi Anukul,

This is a bug. I've filed a bug report here: https://github.com/cucumber/cucumber/issues/856

Cheers,
Aslak

--
Posting rules: https://cucumber.io/support/posting-rules
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cukes/58e2a324-bfe3-4696-ac79-32d4036a7365%40googlegroups.com.

Anukul Singhal

unread,
Jan 12, 2020, 8:17:04 PM1/12/20
to Cukes
Thanks Aslak!


On Sunday, January 12, 2020 at 2:50:36 PM UTC-6, Aslak Hellesøy wrote:
Hi Anukul,

This is a bug. I've filed a bug report here: https://github.com/cucumber/cucumber/issues/856

Cheers,
Aslak

To unsubscribe from this group and stop receiving emails from it, send an email to cu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages