-
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 not working with @QuarkusIntegrationTest
s
#18559
Comments
/cc @geoand |
/cc @stuartwdouglas PS: Maybe we should add a labeling rule for "jacoco". |
Did this ever work? It looks like you are manually running a process with the Jacoco args, which will use the transformed classes, but it will only generate the report from the classes in target/classes, which are not transformed. |
@stuartwdouglas no, this is an attempt to move to the Quarkus documented way of working with Jacoco, since currently we are still using offline instrumentation but with the upgrade to Quarkus 2 (no other changes) we lost some coverage. I see what you mean, but isn't this the way things are documented to work also for |
What is not working? |
Jacoco finding the right classes and reporting the right coverage for integration tests as documented in the guide. Unless I did something wrong the reproducer is configured as in the guide but not working properly. |
I've been looking at JaCoCo configuration parameters and at the Quarkus JaCoCo extension and I'm not sure I know enough about how things work behind the scenes to get things working... I tried relying on the extension to generate the report for integration tests instead of the JaCoCo maven plugin, but it didn't work... I wonder if in this case is just that the extension is somehow not triggered for integration tests or not at the right time... I'm pretty sure though things don't work as documented in https://quarkus.io/guides/tests-with-coverage#coverage-for-integration-tests (for integration tests, as @stuartwdouglas pointed out). So, @stuartwdouglas @geoand any chance you can take a look at providing JaCoCo support for integration tests (or if there's a configuration that should currently work)? Hopefully, if things work for |
Having a quite similar issue here. After upgrading to quarkus 2.0.0-2.0.2 (from 1.13.6), jacoco-report folder with the report is not being generated in the gradle "check" phase |
As mentioned in #9623, I had issues when upgrading to 2.0 with integration tests and jacoco. However. Since that issue was closed, I've been having nothing but success in my projects with regards to jacoco and integration test coverage. I am using the jacoco-maven-plugin, as I've not been able to get the extension to work and append the results. I'd suggest bumping to a newer release of quarkus and trying again. |
I already tried with the latest Quarkus version I haven't been able to get JaCoco to work with |
1.) Yes. I'm using @QuarkusIntegrationTest.
This will get everything into the I have a philosophical issue with running Integration Tests as part of the surefire (unit test) phase. Mainly that I require extra setup & tear-down for those fixtures, which I can get with maven lifecycles -- Also separating those things out lets me completely exercise and test my database migrations as well. This 'ram everything into surefire' stuff Quarkus does by default is rather off-putting, and causes issues when you're trying to actually do a real integration tests. I understand your frustration. This gave me fits for some time before I got it all setup and working. The magic sauce was:
|
I don't get it. I don't see any significant difference and it doesn't work... @bvarner any chance you could run this reproducer (same as second one above but updated to 2.2.1) and report if it works for you or not or if you spot any configuration errors? It contains a simple resource that is only tested by a
|
quarkus-reproducer-single-module.zip Another reproducer. This time a single Maven module project (in case multi module was the issue). Same result... @stuartwdouglas @geoand, before I give up on this, the reproducer is really simple, any chance you could take a look? Otherwise, is there a better chance that creating an example/quickstart (that hopefully includes Thanks. |
So the problem is that you seeing decreased code coverage when moving to Quarkus 2.x? |
@geoand no, sorry if that was confusing. That was the trigger to trying to migrate from offline instrumentation to use JaCoCo as explained in https://quarkus.io/guides/tests-with-coverage, but the drop was caused by something else. The problem is that we still need to move away from offline instrumentation and I can't get JaCoCo to work for |
My initial guess was that this happens because Quarkus loads the applications in a special classloader. I have actually never used Jacoco myself, so I had to debug the code and see what was going on. Alternatively, @stuartwdouglas maybe we could consider copying (and replacing) the transformed classes into the build target output as well? WDYT? |
FWIW, I wouldn't hold my breath w.r.t. new jacoco-maven-plugin features: jacoco/jacoco#902 (comment) |
I see, thanks! In that case, the alternative I proposed should work and it's likely not hard to do. |
To make this work, essentially what we do is to overwrite the build system output with the transformed bytecode See quarkusio#18559 (comment) for more details. Fixes: quarkusio#18559
#20075 takes care of the problem |
To make this work, essentially what we do is to overwrite the build system output with the transformed bytecode See quarkusio#18559 (comment) for more details. Fixes: quarkusio#18559
This is mainly done in order to allow code coverage tools to skip the constructor Relates to: quarkusio#18559
@geoand thanks for looking into this!
My understanding is that the JaCoCo extension was solving that somehow, but it's not working for integration tests. Maybe @stuartwdouglas knows more? That said, @geoand, your solution seem really simple to make that part work... Does JaCoCo work out-of-the-box then or is the JaCoCo extension still needed? I hope we can get this solved soon. Thanks! |
It turns out that #20075 could cause subtle issues so it was not merged. Stuart has proposed an alternative that might work, but I have not looked into it. |
@QuarkusIntegrationTest
s
To make this work, essentially what we do is to overwrite the build system output with the transformed bytecode See quarkusio#18559 (comment) for more details. Fixes: quarkusio#18559
To make this work, essentially what we do is to overwrite the build system output with the transformed bytecode See quarkusio#18559 (comment) for more details. Fixes: quarkusio#18559
Make jacoco work with @QuarkusIntegrationTest
To make this work, essentially what we do is to overwrite the build system output with the transformed bytecode See quarkusio#18559 (comment) for more details. Fixes: quarkusio#18559 (cherry picked from commit 18939d3)
Hey, finally got time to properly look into this again and I got it working, but The only way I got both unit and integration tests reporting the right coverage together (on a very simple maven single module project) was by:
Attaching working single module project for reference: tests-with-coverage-quickstart-single-module.zip On a multi module project with an aggregated JaCoCo report though, there's always some incompatibilities between the classes that were unit tested and the classes that JaCoCo sees when doing the report (or the other way around if for example I tell Quarkus to not remove "unused" classes). After coming to know that the classes are copied during the cc @geoand and @stuartwdouglas in case you have some comments/suggestions or think it's worth to create some issues. |
can not work with muti module |
Describe the bug
After upgrading to Quarkus 2 we saw a test coverage loss of 6% for both unit and integration tests.
I've tried to change how we have everything setup following https://quarkus.io/guides/tests-with-coverage (since we were still using offline instrumentation), starting with our integration tests, but I can't get things to work right (JaCoCo complaints about classes not matching execution data). I've created a small reproducer (linked below) by setting up the necessary parts as in https://quarkus.io/guides/tests-with-coverage and then having the following test (since we can't use
@QuarkusIntegrationTest
for a couple of reasons):I also tried then with a REST resource and a proper
@QuarkusIntegrationTest
(reproducer also linked below) and got the same result: JaCoCo still complaining and showing a coverage of 0%.Expected behavior
Can get JaCoCo working together with Quarkus, finding the right classes and reporting the right coverage.
Actual behavior
And JaCoCo reports an incorrect coverage (0% in the reproducers).
To Reproduce
quarkus-reproducer-1.zip
quarkus-reproducer-2.zip
Environment (please complete the following information):
Output of
uname -a
orver
Darwin xtaixe 20.5.0 Darwin Kernel Version 20.5.0: Sat May 8 05:10:33 PDT 2021; root:xnu-7195.121.3~9/RELEASE_X86_64 x86_64
Output of
java -version
Quarkus version or git rev
2.0.1.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)The text was updated successfully, but these errors were encountered: