Error message ArrayIndexOutOfBounds with Clover for Android

Frederik Petersen November 15, 2012

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

1 vote
Answer accepted
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 3, 2012

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

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 23, 2012

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

0 votes
Frederik Petersen November 16, 2012

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!

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 15, 2012

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.

0 votes
Marek Parfianowicz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 15, 2012

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)?

0 votes
Frederik Petersen November 15, 2012

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

0 votes
Frederik Petersen November 15, 2012

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events