I’m having trouble understanding how test --cover is working. I see a module has 0% coverage, add a test for the function defined in that module and test --cover still says 0% for that module. Also, not sure why it is flagging some functions not defined in the module as needing tests. Here is an example of what Im talking about:
defmodule Core.Tenants.Settings.CheckoutTest do
@moduledoc false
use ExUnit.Case, async: true
alias Core.Tenants.Settings.Checkout
@valid_attrs %{asset_key: "some string"}
@invalid_attrs %{}
test "changeset with valid attributes" do
changeset = Checkout.changeset(%Checkout{}, @valid_attrs)
assert changeset.valid?
end
test "changeset with invalid attributes" do
changeset = Checkout.changeset(%Checkout{}, @invalid_attrs)
refute changeset.valid?
end
test "asset_key is required" do
changeset = Checkout.changeset(%Checkout{}, Map.delete(@valid_attrs, :asset_key))
refute changeset.valid?
end
end
Yeah the test runs. I should probably also add this is an umbrella app.
EDIT: so actually the test wasn’t running because the file name had tests instead of test. This still only generated 66% coverage for the file though so still a little confused.