Compilation order during tests

I was experiencing this as well. My solution involved using use MyApp.MyBehaviour. This required that I implement def __using__(_) as so:

defmodule MyApp.MyBehaviour do
  @moduledoc """
  Behaviour definition
  """

  @type entry_attrs_t::map
  
  @callback create_entry(entry_attrs_t) :: any 

  def __using__(_) do

  end
end

and then in test/support/mocks.ex:

use MyApp.MyBehaviour
defmodule Mocks do
  @moduledoc false
end


Mox.defmock(MyApp.MyMock, for: MyApp.MyBehaviour)

kinda hacky, but not horrible…