I have an umbrella project with several apps.
Some of these apps have runtime libraries as dependencies, some apps depend on others and so on.
My objective is, when on the root level of the project, to run all the tests for all the child apps using
When on the root level, running
mix test will run the tests of all child apps. However this happens in a parallel way, from what I can see.
This is a problem because some dependencies between child apps are shared. Consequently some apps succeed, and others fail, thus breaking my CI/CD pipeline.
This is not a problem at all if I run the tests for each child separately, but alas, I want to be able to use
mix test from the root level.
So, my initial approach was create an alias that replaces
mix test with my own command:
defp aliases do
test: ["cmd --app app1 mix test --color", "cmd --app app2 mix test --color"]
This will work and will execute the tests of the child apps sequentially.
However this solution is hard-coded and not very flexible. If tomorrow I remove an app, the command will break. If I add a new one, the command won’t run its tests unless I remember to edit it.
I wonder if there is a better way of doing this that would be:
- flexible instead of hard-coded
- run the tests sequentially instead of parallel