Got java.lang.ArrayIndexOutOfBoundsException:55 after run a feature file

getting the below error after running a faeature file ERROR c.k.k.core.keyword.internal.KeywordMain - :x: Keyword runFeatureFile was failed (Root cause: java.lang.ArrayIndexOutOfBoundsException: 55
at cucumber.runtime.formatter.TestSourcesModel.getKeywordFromSource(TestSourcesModel.java:124)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.getKeywordFromSource(JUnitFormatter.java:287)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.addStepAndResultListing(JUnitFormatter.java:277)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.addTestCaseElement(JUnitFormatter.java:232)
at cucumber.runtime.formatter.JUnitFormatter.handleTestCaseFinished(JUnitFormatter.java:134)
at cucumber.runtime.formatter.JUnitFormatter.access$300(JUnitFormatter.java:42)

could anyone help me on this please, also I have referred the forum which someone has posted same issue, but no solution for that.got java.lang.ArrayIndexOutOfBoundsException: 28 after run a feature file - #5 by andyca

To me, this seems to be due to some bug in Katalon Studio.

You need to ask Katalon developers to look at it.

This Katalon Forum is a community of users who have no capability to debug Katalon products.

@Elly_Tran @vu.tran

I found the source code of cucumber.runtime.formatter.TestSourcesModel.getKeywordFromSource(TestSourcesModel.java:124) at

    String getKeywordFromSource(String uri, int stepLine) {
        Feature feature = getFeature(uri);
        if (feature != null) {
            TestSourceRead event = getTestSourceReadEvent(uri);
            String trimmedSourceLine = event.source.split("\n")[stepLine - 1].trim();   // ArrayIndexOutOfBoundsException is raised here
            ...

If the stepLine variable has 0 value, then an ArrayIndexOutOfBoundsException will be raised.

I believe @shabana.sreenivasulu saw it.

You can check which version of the cumber-jvm project Katalon uses. See the .classpath file in your Katalon project. Katalon Studio v8.6.5 uses v3.0.2 of the cucumber-jvm library.

	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.core_3.0.2.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.datatable_1.0.3.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.datatable-dependencies_1.0.3.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.expressions_5.0.19.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.gherkin_5.0.0.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.html_0.2.7.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.java_3.0.2.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.tag-expressions_1.1.1.jar"/>
	<classpathentry kind="lib" path="/Applications/Katalon Studio.app/Contents/Eclipse/plugins/io.cucumber.junit_3.0.2.jar"/>

The v3.0.2 of cucumber-jvm is very old. The latest version is v7.13.0.

As you see, Katalon Studio is not in sync with the cucumber-jvm project.

It is quite likely that the v3.0.2 had some bugs. These bugs would have been fixed in the later versions; but Katalon Studio is not able to benefit these fixes.


@shabana.sreenivasulu

Unfortunately, this issue will be very difficult for Katalon team to fix. They would have to start with upgrading the external dependencies (e.g., to cucumber-jvm.7.13.0). It will inevitably involve a lot of work.

In April this year, @duyluong wrote that they will work on “overhauling” their product to catch up the latest version of various external dependencies;

However we haven’t heard of any progress of the great attempt yet.

Katalon Studio provides a way to replace the external dependencies while excluding the bundled old versions:

I suppose that you will get problems if you try to replace the bundled old version cucumber-*.jars to a newer version. Why?

Since version 4.5.0 the package cucumber.api.junit.Cucumber has moved to io.cucumber.junit.Cucumber and package cucumber.api.CucumberOptions has moved to io.cucumber.junit.CucumberOptions

This change of package name from cucumber.* to io.cucumber.* is quite significant. Any code dependent on the cucumber.* package (v3.0.2) will fail to run with a cucumber of newer version (e.g, v7.13.0).

Hi,

Thank you for sharing the issue. I will ask my internal team and back to you soon. We need to reproduce before confirming this as a bug. Thank you!

1 Like

Thanks @kazurayam , I have verified in the classpath file , the version is 3.0.2 which is the older version.

Thanks @Elly_Tran , waiting for your response.

Hi,

can you please share the projects and step to reproduce so that my team can support? If you are a paid user, please help submit a ticket here Katalon Help Center. Thank you

Hi,

Inside your lines of code (in test case or step definition), if you’re trying to call CucumberKW.runFeatureFile(), this error is displayed. Instead replace the Gherkin lines from a feature file you’re calling to the current feature file that is running, the issue got addressed. Please try and share your thoughts.

Hi,
Basically I’m calling another feature in one feature file to get the variable values to be used in current feature file using call Testcase() as we can’t use varaiables in one feature file to another. That time I’m getting this error in current feature file.

Are you sure that the “one feature file” is always present?

I guess, when you miss the “one feature file” on disk, you get the java.lang.ArrayIndexOutOfBoundsException; don’t you?

In that case, your code should check if the “one feature files” is present or not before it calls the feature contained in the “one feature file”. If the file isn’t present, of course, your code should not go forward. You code should branch the processing as appropriate.

In feature file 1(actual file)> calling feature file 2 tests using call test case> In this I’m calling feature file 3 tests as I want to do all these feature file 3 and 2 before running feature file1.

When I run feature file1>it is calling feature file2> which calls feature file 3, and feature file 3 is running successfully and feature file2 all steps are running fine , but at the end I’m getting this exception.After that Feature file is also running the tests. But at the end I’m not able to see either test has passed or failed bit in console it is displaying this error.

All these feature files I’m running beacuse I want to use variables of feature file 2 and 3 in feature file file1

Got the same issue on Katalon 8.6.8

=============== ROOT CAUSE =====================

For trouble shooting, please visit: https://docs.katalon.com/katalon-studio/docs/troubleshooting.html

11-28-2023 03:12:53 AM SCENARIO Approver is able to approve form

Elapsed time: 2m - 51.083s

Keyword runFeatureFileWithTags was failed (Root cause: java.lang.ArrayIndexOutOfBoundsException: 90
at cucumber.runtime.formatter.TestSourcesModel.getKeywordFromSource(TestSourcesModel.java:124)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.getKeywordFromSource(JUnitFormatter.java:287)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.addStepAndResultListing(JUnitFormatter.java:277)
at cucumber.runtime.formatter.JUnitFormatter$TestCase.addTestCaseElement(JUnitFormatter.java:232)
at cucumber.runtime.formatter.JUnitFormatter.handleTestCaseFinished(JUnitFormatter.java:134)
at cucumber.runtime.formatter.JUnitFormatter.access$300(JUnitFormatter.java:42)
at cucumber.runtime.formatter.JUnitFormatter$4.receive(JUnitFormatter.java:71)
at cucumber.runtime.formatter.JUnitFormatter$4.receive(JUnitFormatter.java:68)
at cucumber.runner.EventBus.send(EventBus.java:28)
at cucumber.runner.TestCase.run(TestCase.java:58)
at cucumber.runner.Runner.runPickle(Runner.java:44)
at cucumber.runtime.Runtime.runFeature(Runtime.java:120)
at cucumber.runtime.Runtime.run(Runtime.java:106)
at cucumber.api.cli.Main.run(Main.java:35)
at cucumber.api.cli.Main$run.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFileWithTags_closure2.doCall(CucumberBuiltinKeywords.groovy:204)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$_runFeatureFileWithTags_closure2.doCall(CucumberBuiltinKeywords.groovy)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:75)
at com.kms.katalon.core.keyword.internal.KeywordMain.runKeyword(KeywordMain.groovy:69)
at com.kms.katalon.core.keyword.internal.KeywordMain$runKeyword.call(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFileWithTags(CucumberBuiltinKeywords.groovy:164)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords$runFeatureFileWithTags.callStatic(Unknown Source)
at com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords.runFeatureFileWithTags(CucumberBuiltinKeywords.groovy:287)
at 1140186.run(1140186:21)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:448)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:439)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:418)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:410)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:285)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:144)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1701115953591.run(TempTestCase1701115953591.groovy:25)
)