Code coverage questions
Hi all,
I have just starting trying out the code coverage support and have a few questions.
1. Why am I getting many, many blank lines and javadoc marked as red (not executed)? They make it much more difficult to find the real code lines that are not executed. Is this an error in the code coverage line parser?
2. Sometimes I will get a multi-line method call in which some lines are marked as executed, and others not-executed:
myMethod(param1, param2, // <- executed
param3, param4); // <- not executed
(note, the parameters are local variables, not method calls of their own)
Is this trying to tell me something about whether the parameters are used, or is it another problem with the line numbers?
3. The following line is being marked as partially executed, but I don't see how this is possible. Is there something going on here I don't understand?
boolean isInitialized = someInstance != null; // <- partially executed
From seeing some other comments, I have gotten the idea that there may be problems due to the bytecode compiler being different from the source code. Is that what I am seeing here? If so, is there any way to increase the accuracy?
Thanks,
-Bruce
Please sign in to leave a comment.
Bruce,
the issues could come from the compiler, but it could also be a bug in IDEA applying coverage results in the editor. If you could make a small test project demonstrating the problem, I will certainly try to figure out who is wrong.
multiline statements don't appear to be highlighted correctly. I suppose this is a limitation of the code coverage information? See attached for examples. All my multiline if statements only have the first line colored green.
Attachment(s):
5594_code_coverage_multiline_if_statement.png
5594_code_coverge_multiline_static_init_statement.png
Attached is example where statement "while(true) { is not marked green.
Also, in the switch statement the "case:" label and the "break;" are not marked green,
but farther down there is a "break;" statement marked red.
Attachment(s):
5594_code_coverage_switch_statement.png
This is the usual case with the compiler binding debug information to the first line of the multiline statement. While I wish I could work around this, I'm afraid it is not possible.
FWIW, here's another example of coverage information that I don't understand. Anyone got
an idea why the line in the screenshot is only partially covered? Happens with all return
statements that contain method calls I've seen so far...
Sascha
Attachment(s):
partial-coverage.PNG
Thats an effect of NotNull instrumentation you are using. It essentially adds code to return statement that is usually not executed, and not suposed to be. This looks like a bug in instrumentation, that I'l try to fix.
Fixed.
It's around 13 years later, and I'm getting a similar bug in PyCharm:
Multi-line functions seem to sometimes be covered.
My comments aren't "covered"
And sometimes...the...middle...of...my...multi-line...function...isn't...covered.
Scratch that. Updated to the latest version. Should've done that before opening a bug. It's not an issue in the latest edition of Pycharm.