-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:32:32] [ds:32:32:10] [async-threads:1] [jit:ns]
Elixir 1.17.0 (compiled with Erlang/OTP 27)
Operating system
Linux
Current behavior
After creating a project structure with the following files:
# mix new coverage && cd coverage
# cat > lib/coverage.ex
defmodule Coverage do
defstruct x: %{},
y: %{},
z: %{}
def new(opts) do
struct!(__MODULE__, opts)
end
end
# cat > test/coverage_test.exs
defmodule CoverageTest do
use ExUnit.Case
test "exercises all functionality" do
assert %{} = Coverage.new(x: "x", y: "y", z: "z")
end
end
running mix test --cover
produces a report where only 50% of the module has coverage:
Percentage | Module
-----------|--------------------------
50.00% | Coverage
-----------|--------------------------
50.00% | Total
However, every executable line contained in this file was executed. In the HTML report, one can observe that this is caused by the defstruct
line, presumably due to the two clauses of the __struct__
function:
Expected behavior
This test run should have 100% coverage.
fuelen, lorisp1, wu3rstle, pnezis and pojiro