Run mix test multiple time for different set of tests

Hello everyone.

I have set of tests that I want to run in separate runs but with one mix command (mostly because of the ‘recompilation issue’ in github CI action GitHub Action Cache Elixir always recompiles dependencies (Elixir 1.13.3)).

I am executing:

- name: Build and run tests
  run: |
    mix do compile, ecto.migrate --all, credo --all, test --trace, reenable, test --only property_based_test

Where reenable is a custom simple mix task to be able to run mix test second time:

def run(_args) do
  Mix.Task.reenable(:test)
end

The issue is in the last command: test --only property_based_test instead of running tests tagged with the property_based_test I see the:

Excluding tags: [:test]
Including tags: [:property_based_test]
Finished in 0.00 seconds (0.00s async, 0.00s sync)
0 failures
Randomized with seed 916282
The --only option was given to "mix test" but no test was executed
Error: Process completed with exit code 1.

Any hints why tests are not launched and I am getting this error instead?

Thank you.

According to first line of the output you shared, you are excluding tests with the tag :test. Apparently all tests are tagged with :test which I wasn’t aware of until I just ran mix test --exclude test in a project with only a couple of :skip tags and all tests were skipped. I don’t see where you would be doing that in your command but it must be happening somewhere!

1 Like