IntelliJ: (Coverage): Error during class instrumentation: ... java.lang.ArrayIndexOutOfBoundsException
Asked Answered
S

2

41

This affects both IntelliJ 2019.3 and 2020.1 (latest as of this post) Ultimate Editions.

Code coverage is missing for some classes, while other classes continue to show coverage. Stating the obvious, but the classes that do not show coverage data in fact should show it because those lines are hit by the tests.

Error that is seen is:

[2020.04.23 23:52:20] (Coverage): Error during class instrumentation: com.<redacted>: java.lang.ArrayIndexOutOfBoundsException: 113
[2020.04.23 23:52:20] (Coverage): Error during class instrumentation: com.<redacted>: java.lang.ArrayIndexOutOfBoundsException: 144

Note that the redacted part is the actual fully qualified class path. The tests execute correctly, but the coverage data is missing.

I have ensured that the tests are set up for coverage correctly:

  • Coverage runner is IntelliJ IDEA
  • Packages and classes to include in coverage data are accurate

Does anybody know how to get past this so that the missing classes show coverage info?

Schmidt answered 24/4, 2020 at 7:16 Comment(8)
Yes, but it is not the test (the code that we handle) is what's giving out that error. Tests execute to completion irrespective of the error. I'm trying to determine the source of why the error is in the first place (something that our code doesn't control).Schmidt
If possible please file a bug at the YouTrack (youtrack.jetbrains.com) providing a little reproducible sample project. Thank youZloty
We have similar problem, (Coverage): Error during class instrumentation: com.<redacted>: java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 14Oaken
Having the same problem...Alvey
How you guys handle this issue?Modiolus
To get around it, we now run code coverage externally using Jacoco/SonarQube.Schmidt
I have made some progress on this. The exception and the issue with the code coverage MIGHT not be related to each other. What I've tried to do is to create a new file and type all the code back as it was. This fixed the code coverage. What was the issue or how to resolve it? Not sure. Probably something copy-pasted from a web browser or Slack. I'll keep you posted if I'll make any progress.Marolda
What's on lines 113 and 144 of the code not being covered?Pyroelectric
S
2

This seems to be the bug that is reported is IDEA-269838.

It is currently marked as resolved / fixed without specifying the version in which it is fixed. I think that means that the fix will be in Intellij IDEA 2021.3 which is due this month (November 2021) according to the JetBrains website.

Schlesien answered 21/11, 2021 at 14:58 Comment(0)
W
-7

I think the problem is that if you have a loop like this over an array

for (int i = 0; i <= arr.length; i ++)

Then you shouldn't have <=. You must do this <, otherwise your loop is outside the array

Walloper answered 20/10, 2021 at 13:51 Comment(2)
The answer is not totally related to the question, as it is a inferred by a possible error in programming (the answer's author says "I think the problem is"). Moreover, the asker doesn't give a code chunk that clarifies about the error...Pit
If you have a new question, please ask it by clicking the Ask Question button. Include a link to this question if it helps provide context. - From ReviewKind

© 2022 - 2024 — McMap. All rights reserved.