Hey Elixir-land!
It’s been a while since I’ve been around. Getting back into lots of elixir work and I found something unexpected regarding the coverage system. Essentially function calls wrapped in literals don’t seem to get counted as coverable statements.
Steps to reproduce:
- run
mix new coverage_why
- paste in
lib/coverage_why.ex
defmodule CoverageWhy do
def hello do
:world
end
def i_has_coverage do
hello()
end
def i_has_no_coverage do
{:ok, hello()}
end
def i_has_no_coverage_as_well do
[hello()]
end
def i_has_no_coverage_as_either do
[hello()]
:ok
end
end
- run
mix test --cover
I get the results of
Expectations
I would expect all the lines except the original def hello...
to be uncovered. If I had to guess the wrapping the call in a literal causes the function call to be inlined somehow. Is this the expected coverage results and is it documented anywhere?