Shared test components across umbrella apps

I have an umbrella solution, each app with its own set of tests. I’ve come to a point where there is a module, call it TestEventHandler, that is useful in multiple tests across applications and I don’t want to duplicate it in the test/support folder of every app. I also don’t want to include it as application code per se just to remove the possibility that this module somehow got compiled into production code.

Does elixir/exunit have an “official” way to share test code in the way I’m suggesting? Thanks for taking the time to read this :slight_smile:

You can mark dependencies as “only in some MIX_ENVs”, so you could put the common helpers into a separate “app” under apps/ that’s used in other application’s mix.exs as:

{:my_test_helpers, umbrella: true, only: [:test]}
1 Like