Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lines before exception are not included in the coverage result #109

Open
andre15silva opened this issue Oct 11, 2021 · 1 comment
Open

Comments

@andre15silva
Copy link
Member

andre15silva commented Oct 11, 2021

Source code lines with exceptions show no coverage. Why?

JaCoCo determines code execution with so called probes. Probes are inserted into the control flow at certain positions. Code is considered as executed when a subsequent probe has been executed. In case of exceptions such a sequence of instructions is aborted somewhere in the middle and the corresponding lines of source code are not marked as covered.

From: https://www.jacoco.org/jacoco/trunk/doc/faq.html

This means that there are some cases (such as the ones identified in SpoonLabs/nopol#220 (comment)) where lines just before an exception are not included in the coverage result from Jacoco, and consequently on the final Flacoco result.

To fix this, we would have to rewrite the probe insertion/analysis part of Jacoco to add a probe at the beginning of each line. This would be a fundamental change in the way Jacoco works.

Alternatively, we could consolidate and use https://github.com/JetBrains/intellij-coverage, which does work for these cases

We could also reverse engineer the bytecode control flow probe placement of JaCoCo and post-process class files when we do the stack-trace parsing.

@andre15silva
Copy link
Member Author

We will try to parse the source code of classes present in stack-traces and meant to be included in the coverage computation, such as to include lines in the block of the line that threw the exception.

It potentially minimizes this limitation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant