-
Notifications
You must be signed in to change notification settings - Fork 157
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
multiproject reports using coverageAggregate are incomplete #87
Comments
👍 Running into this issue w/ a multi-subproject Play app as well. In our case, we have integration tests written in the main/root app, where we inject concrete implementations for interface-typed constructor params in our subprojects' controllers. Like @johnynek , we are seeing that the coverage provided by these tests (in our root project) are not counted in the aggregated report. cc @mauhiz |
+1 |
I'm experiencing this as well, I check regularly hoping for an update on the issue. I tend to write libraries with the following multi-project structure:
So providing a separate testkit can be used to write tests more easily for the users of the library, and the actual example-tests would also depend on the example-testkit to write the tests for the library. This project structure just makes scoverage output 0% coverage on the main project, which makes it not very useful for this use case. |
Aggregated coverage seems to be working only after two consecutive runs of |
@kamilkloch you are right, the two consecutive runs do generate a usable report. The first one yields 0% test coverage but the second time it correctly generates the report. I noticed though that using this approach generates broken links to the file sources in the report, the original issue about this was here: #69 |
@bfil My aggregated links are fine, are you using sbt-coverage 1.1.0? |
Oh no that was my fault, I tried on a different project which was still on 1.0.4, on the projects using 1.1.0 the links are fine! |
I have the same problem, but running "test" twice doesn't fix it for me. I have uploaded a sample project to https://github.com/RichardBradley/sbt-scoverage-multiproject-sample If I run
then I don't get any report for the "util" project: "No subproject data to aggregate, skipping reports" Is there a workaround? |
I've found a workaround for my case:
I found that running
would instrument the main project but not the "util" project, but running
would instrument the "util" project but not the main project. EDIT: I'm testing if instrumentation was applied using "javap":
Something is definitely up with the "coverage" command in multi-project builds. |
I have a new version of the "coverage" command which fixes this for me:
Now for the https://github.com/RichardBradley/sbt-scoverage-multiproject-sample project, if I run:
then I get a working coverage report. I'll create a PR to update the |
Thanks for your work on this Richard. |
#87 Fix 'coverage' command for multi-project builds
That project seems to work for me for both ver 1.1.0 and my proposed 1.3.1 (from pull #129). I'm running
@bfil -- does the fix in pull #129 work for you?
You're welcome -- I need this for my own projects, so it's mostly selfish :-) |
@RichardBradley yep, I'm subscribed to it, just showing interest, anyway I will try it as soon as I can, thanks! |
Argh, really sorry that I introduced that regression :'( |
@RichardBradley, unfortunately, scoverage 1.3.1 still does not work for me, now in two ways:
|
@kamilkloch -- Please could you post a repro and describe the expected and observed behaviour? The two behaviours you describe work for me with 1.3.1 in the sample project https://github.com/RichardBradley/sbt-scoverage-multiproject-sample as described above. Thanks, Rich |
Hang on; there's something wrong with the published 1.3.1 JAR. |
I think it still doesn't work. Were there any changes since the last time it was brought up? |
I've just tested on @RichardBradley 's test project with version 1.3.5 and it works. Can you provide another test project? |
@gslowikowski it performs tests for all modules and aggregates them correctly (which I think is what the fix in this comment thread did), but I think it doesn't solve the original issue of one module using code from another module in its tests and getting coverage only for the code in its own module. Consider a project with Module A and Module B. If you write tests in Module A/tests that use both the code from Module A and Module B (Module A depends on Module B), you will only get coverage for packages and classes in Module A and not Module B. Does this make sense? |
This was discussed before. You need two runs. First |
@gslowikowski yeah, I was running |
@oleg-gr I need test project |
@gslowikowski was creating a very simple project to reproduce the issue I was facing, but instead now running |
@oleg-gr in your project you have Java classes, not Scala. Scoverage cannot instrument Java classes. Use Cobertura or JaCoCo. |
Makes sense. For some reason since I was using junit-interface I ended up thinking I should use sbt-coverage |
this doesn't work in the scenario where the subproject has an inverted relationship |
Is that even allowed? It doesn't seem logically consistent for a sub-project to depend to the parent-project, it sounds like a circular dep to me (on the assumption that the sub-project is "part of" the parent project). Why would you want that? I suppose if SBT allows it, then |
Does anyone know how to generate the report if some test case fails? what are the commands? |
@VarnitaJain - the same way as usual - |
I'm encountering a similar problem for multi-module project.
however it only cover the tests that is in the parent folder, and it does not go into the modules folder at all. |
suppose you two subprojects: core and tests. Now, in tests, there are is some test harness code that makes it easier to run your tests that others might want (in tests/src/main). Then you exercise this harness in tests/src/test. The coverage for core/src/main that you get from the tests in tests/src/tests will be excluded from the report.
The report seems to only aggregate code that is tested IN ITS OWN test directory.
The text was updated successfully, but these errors were encountered: