-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Umbrella projects do not report numbers overall #23
Comments
Is there a way to post a sample for this case? (I'm not so familiar with the umbrella project). |
Here is the sample: README.md explains what I think is the problem. But the gist of it is if you have an umbrella project the coverage might be spread out and later child (dependent) app might be covering something in the parent app. In the case of the sample project subapp1 depends on subapp0 and covers some of the functionality in subapp0 but this coverage never gets accounted for. Cover tool has export/import functionality so in theory it is possible to get an overall coverage of an umbrella project. |
Thank you for the sample, it helps. I understood that it's about the function The current If the |
I may have a similar issue. Whenever I run Edit: I think I fixed it, no idea how. |
@hunterboerner thanks for the report. If you could reproduce the error next time, mix.exs definition (or entire project if possible) would be helpful for identifying the issue. |
I've tried to check on reporting the entire umbrella project, but haven't been able to find a good way yet. What I found so far is (as a remembering note),
The each sub-projects are isolated at lower-level and haven't been able to find a good hook-point of coordination.. |
The v0.4.0 added
The |
We're running into this issue, too. I think the solution is to run all the tests for all applications as a single unit instead of running each sub-apps tests, one by one. We've achieved this by defining a defmodule Delorean.Mixfile do
use Mix.Project
def project do
[
# ...
test_paths: test_paths,
# ...
]
end
defp test_paths do
"apps/*/test" |> Path.wildcard |> Enum.sort
end
end
# `mix test` cd's into each app directory in sequence and runs the tests.
# `mix test_all` runs tests for all apps at the same time.
defmodule Mix.Tasks.TestAll do
use Mix.Task
@shortdoc "Runs all delorean tests at once"
defdelegate run(args), to: Mix.Tasks.Test
end (Unfortunately, setting We've been using
Any ideas how to deal with this? |
Thanks for the information, I could simulate the indicated behavior. It's interesting, but the same error occurs with default About the error
Possible solution cover =
if opts[:cover] do
cover[:tool].start(Mix.Project.compile_path(project), cover)
end If this part in |
Thanks for digging into this, @parroty. I think asking the Elixir team about this is the way to go. I've been meaning to bring up the idea of having elixir natively support running all tests in an umbrella app at once like my On a side note, your links to specific elixir line numbers use the |
Discussion I started with the elixir team is here: https://groups.google.com/forum/#!topic/elixir-lang-core/8wX8i5sEtFg |
Thanks for the comment. I've changed the link the ones in v1.2.0 branch. |
👍
José has some ideas in the thread if you want to take a look. |
@parroty -- is there anything actionable we can do about this based on what was discussed on that thread? |
For For merging the result approach, there might be a way to make special treatment for umbrella project, but I haven't been able to come up with a good one yet...
|
I think I'd like to get the |
I was making some (very rough) experimentation on the following branch.
It sounds like technically working and there might some way to pursue, but I'm not confident on addressing jose's concern mentioned in the mailing list. I'm running out of time, and may check a little more later. elixir/projects/excoveralls_umbrella[experiment]% mix coveralls
==> subapp0
...
Finished in 0.04 seconds (0.04s on load, 0.00s on tests)
3 tests, 0 failures
Randomized with seed 208001
----------------
COV FILE LINES RELEVANT MISSED
100.0% lib/subapp0.ex 9 2 0
[TOTAL] 100.0%
----------------
==> subapp1
.
Finished in 0.00 seconds
1 test, 0 failures
Randomized with seed 291710
----------------
COV FILE LINES RELEVANT MISSED
50.0% lib/subapp1.ex 9 2 1
[TOTAL] 50.0%
---------------- elixir/projects/excoveralls_umbrella[experiment]% MIX_ENV=test mix test_all --cover
....
Finished in 0.05 seconds (0.05s on load, 0.00s on tests)
4 tests, 0 failures
Randomized with seed 878778
----------------
COV FILE LINES RELEVANT MISSED
100.0% apps/subapp0/lib/subapp0.ex 9 2 0
100.0% apps/subapp1/lib/subapp1.ex 9 2 0
[TOTAL] 100.0%
---------------- |
I've reported this discussion upstream in order to check if something can be done, because having an overall reporting is really useful when doing integration tests between umbrella apps. |
After a short chat with @josevalim I realized that something can be done on the coverage tool itself, without the need to touch elixir itself. So I've setup a quick patch: which adds a
Basically the patch added to elixir by @parroty has been moved into the lib itself. Seems to work to me, and it does not impact current mix tasks (for example mix coveralls --umbrella still reports not merged in results). what do you think? |
I played also with --umbrella options, and this is the result: This makes possible to use coveralls.{json, html, detail, whatever} along with --umbrella and have proper results. But still the above setup into umbrella mix.exs must be done, and is lost the message of how many tests are run per subapp when using the --umbrella flag (only total number of tests is shown) |
I need this capability as well, pretty badly, guess I'll monitor this issue... |
@xadhoom Any plan on making a PR to integrate this improvement? Also could we make it work so it would be a flag instead of a task so we can use the integration aggregation for different type of tasks, for example:
|
@adrienmo since there was no real interest from upstream, I never update the patch to latest release, and a lot of stuff is changed, so basically means redo it from scratch. Said that, I stopped to use this feature from my branch, because after gaining better experience in testing I think that maybe is not really needed, since proper unit testing should already cover almost everything without the need to do cross application coverage. And cross application testing is done with integration tests, where you're most interested into correct functionality and not in coverage. jm2c |
@xadhoom I am planning to expose two metrics:
100% coverage in unit test does not mean that the system works, it just means the code is well tested independently. I think having both number is helpful to maintain a healthy codebase on big projects. For junk code I could consider scanning the project for unused public functions (https://github.com/hauleth/mix_unused), but that's not as good as coverage, I also cannot know my current integration test progress (e.g.: I know I tested my N features, but I don't know if I tested all the code path/errors/exception) I think having 2 coverage results and keeping track of both is standard in Java. Both results can also be interesected to give a total, for exemple a 80% coverage for unit test and 80% integration test can give a total of 65% because only 65% of the code is tested both by unit and integration test. (SonarQube, a multi-language code quality gate, is accepting both and doing this combination: https://docs.sonarqube.org/display/PLUG/Java+Unit+Tests+and+Coverage+Results+Import) By the way, I tried to apply your patch to the current version and it seemed to work for me, so I don't think a lot of work would be needed :) |
For the record: the above still holds true, in case anyone wonders (I used the latter one, invoked with I experimented with the approach and by using a rebased version of the patch c.f. here I managed to calculate "integration coverage" in our case. Not sure yet if we're going to go down that path in our case, but it surely has some appeal. |
I am running this coverage tool on an umbrella project and each individual sub-project seems to report its numbers but if one sub-project of the umbrella is a dependent on another then overall numbers are incorrect.
Is there a way to support this already?
The text was updated successfully, but these errors were encountered: