Error message ArrayIndexOutOfBounds with Clover for Android

Hello,

I am trying to use the Clover-for-Android plugin in Eclipse for my Test setup. I followed the instructions on:

https://confluence.atlassian.com/display/CLOVER/Clover-for-Android

Running the App Project on the device works, code coverage can be viewed after manually using the app. When I run the TestProject with "Run as Android JUnit Test" the tests fail with:

java.lang.ArrayIndexOutOfBoundsException

at com.cenqua.clover.PerTestRecorder$One.set(PerTestRecorder.java:219)

at com.cenqua.clover.PerTestRecorder$ThreadVisibilityStrategy$SingleThreaded.set(PerTestRecorder.java:152)

at com.cenqua.clover.GrowableCoverageRecorder$FixedProxy.inc(GrowableCoverageRecorder.java:228)

at eu.fpetersen.robobrain.behavior.BehaviorFactory.getInstance(BehaviorFactory.java:52)

at eu.fpetersen.robobrain.behavior.test.BehaviorFactoryTest.__CLR3_1_7ramiuiez(BehaviorFactoryTest.java:50)

at eu.fpetersen.robobrain.behavior.test.BehaviorFactoryTest.testBehaviorCreation(BehaviorFactoryTest.java:47)

at java.lang.reflect.Method.invokeNative(Native Method)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:169)

at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:154)

at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:529)

at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1448)

The App-Project is set in the BuildPath of the Test-Project and it is exported. The files are successfully created in the data folder on the device. I have no idea what to do to solve this issue.

Do you have any ideas? Feel free to ask for more information about my setup. I don't know what else is worth sharing right here.

Thanks in advance,

Frederik P.

7 answers

1 accepted

This widget could not be displayed.

I found a bug - it's reported in CLOV-1194. As a workaround, disable per-test instrumentation:

  • open Project Properties dialog > Clover page > Test Classes tab
  • select "Don't look for tests, assume everything is application source" option

Regards
Marek

This widget could not be displayed.

I should add, that I found out that some tests run successfully. They also use the MainApp's code and I can't really find a big difference to those methods that fail. The Errors in the different tests do not originate from the same line of my code but it's always the same line of the clover code that throws the exception. As seen above.

This widget could not be displayed.

if you would like to have a peak into the source code, feel free to do so:

http://server.fpetersen.eu/gitweb/?p=robobrain.git;a=tree

MainApp: RoboBrain

TestProject: RoboBrainTest

This widget could not be displayed.

Hi Frederik,

1) Does this exception occur every time you run your tests?

2) Does it happen also when tests are launched first time after a full rebuild (full workspace clean + removal of clover database + removal of coverage files)?

3) How large is your project (number of statements)?

This widget could not be displayed.

Clover for Android is using a coverage recorder with a dynamically resizable buffer with an initial capacity of 1 million elements (statements + branches + methods). I suspect that your project has exceeded initial buffer size. It can happen also when actual code base is smaller, because every time class is recompiled it adds new data to clover.db database. So the point 2) should help.

This widget could not be displayed.

Hi Marek,

thanks for your answers. I'll answer your 3 questions:

1) Yes it does occur every time. Some tests run through, most don't.

2) Yes it happens everytime. I did clean up everything several times, did a full rebuild and still it fails.

3) It has only 1,207(App) + 443(Tests) statements according to the clover coverage explorer. The project is really small, I can't imagine that its size could be a problem..

So I just tried removing the clover databases again, removing the coverage files, rebuilding everything, and running the tests again. No luck. It still fails with the stack trace above.

Thanks again for your help!

This widget could not be displayed.

Hi Frederik,

Could you try the following workaround:

  • open Project Properties dialog > Clover page > Test Classes tab
  • select "Don't look for tests, assume everything is application source" option

This will disable per-test coverage so exception should disappear. (Unfortunately Test Contributions and Test Run Explorer will be empty).

Cheers
Marek

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

119 views 1 3
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you