My Custom ExUnit case isn't being seen and I have no idea why

I wonder if someone can help me riddle this one out!

Inside an umbrella app I have an OTP application. I want to test this OTP application and want to set up a custom case.

This is the directory structure that my tests reside in. user_management/fraud_test.exs is where my test lives and support/case.ex is where my case lives.

main_app
- apps
-- user_management
--- test
---- support
----- case.ex
---- user_management
----- fraud_test.exs

My case is pretty straight forward;

defmodule UserManagement.Case do
  use ExUnit.CaseTemplate

  using do
    quote do
      alias UserManagement.Repo

      import Ecto
      import Ecto.Changeset
      import Ecto.Query
      import UserManagement.Case
    end
  end

  setup tags do
    ...
  end
end

And my test is really simple;

defmodule UserManagement.FraudTest do
  use UserManagement.Case

  doctest UserManagement.Fraud
end

When I run mix test I get the following;

** (CompileError) apps/user_management/test/user_management/fraud_test.exs:2: module UserManagement.Case is not loaded and could not be found
    (elixir) expanding macro: Kernel.use/1
    test/user_management/fraud_test.exs:2: UserManagement.FraudTest (module)
    (elixir) lib/code.ex:370: Code.require_file/2
    (elixir) lib/kernel/parallel_require.ex:57: anonymous fn/2 in Kernel.ParallelRequire.spawn_requires/5

I have to imagine I have fat fingered something, but I’ve used what I think is identical setup in other projects and it works fine.

Any help would be greatly appreciated

1 Like

Does your mix.exs file in the user_management application include the "test/support" path in the elixirc_paths part of the config?

4 Likes

Thanks @benwilson512 - it wasn’t! Do’h!

1 Like