Sivananda Mohanty
Sivananda Mohanty

Reputation: 11

TestNg: getting ArrayIndexOutOfBoundsException: 0 while executing test with maven

I ran into this weird issue recently (3-4 weeks) where I am getting "java.lang.ArrayIndexOutOfBoundsException: 0" for one of the tests in the test suite. The test method runs fine till a certain point before failing with the below exception:

java.lang.ArrayIndexOutOfBoundsException: 0
org.testng.internal.MethodInvocationHelper.invokeWithTimeoutWithNewExecutor(MethodInvocationHelper.java:289)
org.testng.internal.MethodInvocationHelper.invokeWithTimeout(MethodInvocationHelper.java:246)
org.testng.internal.Invoker.invokeMethod(Invoker.java:667)
org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
org.testng.TestRunner.privateRun(TestRunner.java:744)
org.testng.TestRunner.run(TestRunner.java:602)
org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
org.testng.SuiteRunner.run(SuiteRunner.java:289)
org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
org.testng.TestNG.runSuitesSequentially(TestNG.java:1297)
org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
org.testng.TestNG.runSuites(TestNG.java:1144)
org.testng.TestNG.run(TestNG.java:1115)
org.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:283)
org.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)
org.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:120)
org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:386)
org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:323)
org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:143)

Any help or pointer is highly appreciated. The issue is happening only when I do a "mvn test". It runs fine when I run it from the IDEA itself.

Thanks

Upvotes: 1

Views: 1136

Answers (3)

Sean Sheng
Sean Sheng

Reputation: 1

I was using testng release 6.11 and had the same issue with configuring a timeout.

@Test(timeOut=1000)

Upgrading to 6.13.1 and problem went away and I am getting the expected ThreadTimeoutException.

Upvotes: 0

kroe761
kroe761

Reputation: 3534

I was googling this issue myself (I was running TestNG v6.11) and when I read Krishnan Mahadevan's comment above, I tried moving to 6.10. Caused me no issues, and now the @Test timeOut throws a ThreadTimeoutException instead of ArrayIndexOutOfBoundsException. Just in case you want to give that a try.

Upvotes: 0

Krishnan Mahadevan
Krishnan Mahadevan

Reputation: 14746

Please check if the test in question has something to do with timeouts. Recently there was an issue filed in TestNG related to timeouts (details can be found in GITHUB-1493 ) which I fixed.

Your stacktrace that you shared, is pointing me to this issue only.

If its related to that, then am afraid there's no workaround but to start either start using the snapshot version and start using TestNG v.6.13 or higher (when it gets released) or exclude that particular test in question for now (again till TestNG 6.13 which contains the fix is released).

Upvotes: 3

Related Questions