cucumber / cucumber-android

Android support for Cucumber-JVM
MIT License
135 stars 62 forks source link

Case insensitive gherkin not working #83

Closed kanitkarketki closed 1 year ago

kanitkarketki commented 3 years ago

I want to implement case insensitivity in my gherkin for my project such that the following works:

Scenario: test case insensitive gherkin Given i enable WiFi Given I disable WiFi

I wrote the following step definition (for the above gherkin steps) with the following regex:

@Given("^(?i)I (enable|disable) WiFi") public void switchWiFi(String mode) { //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:

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:62) at cucumber.runner.Glue.stepDefinitionMatches(Glue.java:114) at cucumber.runner.Glue.stepDefinitionMatch(Glue.java:96) at cucumber.runner.Runner.addTestStepsForPickleSteps(Runner.java:74) at cucumber.runner.Runner.createTestCaseForPickle(Runner.java:64) at cucumber.runner.Runner.runPickle(Runner.java:49) at io.cucumber.junit.AndroidPickleRunner.run(AndroidPickleRunner.java:46) at io.cucumber.junit.AndroidFeatureRunner.runChild(AndroidFeatureRunner.java:43) at io.cucumber.junit.AndroidFeatureRunner.runChild(AndroidFeatureRunner.java:14) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at io.cucumber.junit.CucumberJUnitRunner.runChild(CucumberJUnitRunner.java:256) at io.cucumber.junit.CucumberJUnitRunner.runChild(CucumberJUnitRunner.java:52) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at io.cucumber.junit.CucumberJUnitRunner$1.evaluate(CucumberJUnitRunner.java:287) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329) at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293) at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306) at org.junit.runners.ParentRunner.run(ParentRunner.java:413) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at org.junit.runner.JUnitCore.run(JUnitCore.java:115) at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56) at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:444) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)

This should ideally recognize (?i) to indicate case insensitivity but throws an exception instead. This issue was found in the cucumber-jvm library, refer https://groups.google.com/g/cukes/c/I5jqlf7L2ZM and fixed in a subsequent release.

The cucumber-android library might need to upgrade the cucumber-java/cucumber-jvm dependency to reflect this change.

lsuski commented 1 year ago

If it's fixed in cucumber then from version 7.14.0 it should work also here