-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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 doesn't cover a class that is an injection by constructor #32254
Comments
when we use the injection by constructor, we see:
and instead of:
|
I'm not a jacoco expert but if you use constructor injection for an Speaking of coverage - does jacoco hanlde CDI at all. I mean the bean is not instantiated directly in the code, so it would need to analyze the injection points (e.g. |
you are right @mkouba: a default constructor with |
Martin is right, the CDI specification requires that every bean with normal scope (which is, among others, In fact, there is more bytecode tempering Quarkus can do (and not just in CDI), so technically you should feed jacoco the sources after Quarkus finishes build, but I am not sure that's possible 🤔 |
hmm. that would be nice. especially because jacoco fails on the class silently (just a warn in the build logs). |
Hm, you can dump the generated classes, so that might be a start if you want to play with it, see https://quarkus.io/guides/writing-extensions#dump-the-generated-classes-to-the-file-system |
I'd like to point out that there is no source code that could be matched with transformed bytecode. If the coverage tool tries to match source code with bytecode, that will inevitably fail in presence of bytecode transformations and there's nothing we can do about that. |
IIRC, Jacoco skips over code if it has the |
This seems to indicate that we do add the proper modifier. |
The idea here is that hopefully it convince code coverage tools to ignore it Relates to: quarkusio#32254
In any case, I opened: #32267. Would anyone be able to try it on their application? |
Interesting, didn't know that.
Yes, that should work. CDI needs any non-private. |
does not seem to happen when using the quarkus jacoco extension |
Thanks for the update @vsevel |
Describe the bug
Hi guys
Today we have a coverage problem with jacoco. An ApplicationScope bean that use an injection by constructor isn't cover by jacoco.
Expected behavior
Jacoco should cover all classes, whatever the way of dependency injection.
Actual behavior
No response
How to Reproduce?
You have an example project by file zip file just at the end of this message.
Output of
uname -a
orver
MSYS_NT-10.0-19045 3.3.6-bec3d608-341.x86_64 2023-02-22 08:29 UTC x86_64 Msys
Output of
java -version
Java version: 17.0.6, vendor: BellSoft, runtime: scoop\apps\liberica17-full-jdk\current
GraalVM version (if different from Java)
No response
Quarkus version or git rev
2.16.5.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.1 (2e178502fcdbffc201671fb2537d0cb4b4cc58f8)
Additional information
jacoco.zip
Thanks !
The text was updated successfully, but these errors were encountered: