-
Notifications
You must be signed in to change notification settings - Fork 22
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
Jacoco breaks when throwing exceptions using .class #208
Comments
According to JaCoCo FAQ 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. This is probably an issue with JaCoCo. We maybe could find a solution by replacing in code .thenThrow(ExceptionName.class) by .thenThrow(new ExceptionName()) |
From a static analysis viewpoint, it's quite cumbersome to replace the right code. I'm not convinced there is an easy solution that will cover all the cases, and in my opinion we should redirect the efforts to:
|
I also think that, given this, the best we can do is to warn students.
Maybe Andy could print a message, something like “hey this is correct but
we then can’t precisely calculate coverage, so please, rewrite it like X”?
On Fri, 7 Jul 2023 at 16:49, Paul Huebner ***@***.***> wrote:
From a static analysis viewpoint, it's quite cumbersome to replace the
right code. I'm not convinced there is an easy solution that will cover all
the cases, and in my opinion we should redirect the efforts to:
1. Bring this up with JaCoCo. Are there any issues relating to this
topic yet? It would be great if we could get a patch.
2. Let students know to instantiate exceptions themselves. Perhaps we
could even automatically detect this, but I fear this would run into the
same issues as above.
—
Reply to this email directly, view it on GitHub
<#208 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAYTTBBIDFTCKZMOHLLGVTXPAOXPANCNFSM6AAAAAAZBTYYAI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
--
*Maurício Aniche*
Author of Effective Software Testing: A Developer's Guide
<https://www.effective-software-testing.com>
https://www.mauricioaniche.com
|
A line such as this causes Jacoco to break and stop counting lines as being covered.
Replacing this with an object instance fixes the problem and Jacoco then works as expected.
The text was updated successfully, but these errors were encountered: