I’ll start off by stating the problem that I’m having.
Basically, unit tests take too long to start up for a ideally superfast TDD cycle. This is because, in our umbrella app, we have many micro services , Each being their own app, and each standing up various other applications like Phoenix endpoints, Prometheus metrics, Various libraries doing things as their app starts up.
I have already done my best to reduce the amount of work being done at applications that up time, but there is still a delay of about six seconds (plus compilation times) for a single hello world test to run.
I have noticed that these two ways of running the test are not equal, especially in terms of speed.
mix test apps/utils/test/hello.exs
cd apps; mix test test/hello.exs
In my umbrella app at work, the first will take about six seconds to run (after repeated runs, to ignore compilation times) but the second will take 1.5. This is because the second option does not start up other umbrella apps
So why not always just do option two? Firstly, umbrella app dependencies Will not be seen unless mix is run from the top level umbrella - dependency overrides for Erlang libraries will appear to be unresolved, and mix test.watch will be unavailable if defined in the top level umbrella mix file.
possible solution: When running tests in an umbrella app, don’t start up other umbrella apps until running a test that is either inside it or depends on it via the test app’s mix file. If this is possible, it would still optimise test start up times when running mix test with —stale or —failed options
Looking forward to hearing thoughts!