dashbitco / mox

Mocks and explicit contracts in Elixir
1.35k stars 77 forks source link

warning redefining module #49

Closed sescobb27 closed 6 years ago

sescobb27 commented 6 years ago

Hi there, i have an umbrella app with a domain app and other apps that depend on that domain, the problem is domain has some 3rd party dependencies and does some rpc calls, i'm mocking them with mox, and I have to use those mocks in different apps (under the umbrella) that don't depend on each other. the problem is when i define for example Mox.defmock(MockClient, for: Domain.Services.Client) in multiple apps and I run the whole test suit from the root directory it prints the warning message bellow, (the warning doesn't appear running each app's test independently), I know i can rename the mock's name, but i was wondering if there is another way of getting rid of that warning, thanks.

warning: redefining module Domain.Service.MockDatabase (current version defined in memory)
  /Users/kiro/esl/release_poller/deps/mox/lib/mox.ex:273
josevalim commented 6 years ago

Yes, the warning in this case is to indeed use different names or have a separate app that you include only during test that defines shared test deps. But it is probably an overkill just for this.

sescobb27 commented 6 years ago

ok, thanks for the fast response ❤️, closing this.

thbar commented 2 years ago

I am facing the same error, in an umbrella app for which I'm trying to add --warnings-as-errors. I wonder if there is a fix for umbrella apps here (although long term I am in the process of merging the apps together, to avoid umbrella-specific problems like this).