diff --git a/lib/ex_unit/lib/ex_unit/runner.ex b/lib/ex_unit/lib/ex_unit/runner.ex index b0ccf4dad0..e8f2fcf23a 100644 --- a/lib/ex_unit/lib/ex_unit/runner.ex +++ b/lib/ex_unit/lib/ex_unit/runner.ex @@ -166,18 +166,23 @@ defmodule ExUnit.Runner do running end - defp spawn_modules(config, [{group, [_ | _] = modules} | groups], async?, running) do - if max_failures_reached?(config) do - running - else - {pid, ref} = - spawn_monitor(fn -> - Enum.each(modules, fn {module, params} -> - run_module(config, module, async?, group, params) - end) - end) + defp spawn_modules(config, [{group, modules} | groups], async?, running) do + cond do + max_failures_reached?(config) -> + running - spawn_modules(config, groups, async?, Map.put(running, ref, pid)) + modules == [] -> + spawn_modules(config, groups, async?, running) + + true -> + {pid, ref} = + spawn_monitor(fn -> + Enum.each(modules, fn {module, params} -> + run_module(config, module, async?, group, params) + end) + end) + + spawn_modules(config, groups, async?, Map.put(running, ref, pid)) end end diff --git a/lib/ex_unit/test/ex_unit_test.exs b/lib/ex_unit/test/ex_unit_test.exs index cc20149cce..5d71be8073 100644 --- a/lib/ex_unit/test/ex_unit_test.exs +++ b/lib/ex_unit/test/ex_unit_test.exs @@ -720,6 +720,30 @@ defmodule ExUnitTest do assert_receive {:tmp_dir, tmp_dir2} when tmp_dir1 != tmp_dir2 end + test "empty parameterized tests" do + defmodule EmptyParameterizedTests do + use ExUnit.Case, async: true, parameterize: [] + + test "hello world" do + assert false + end + end + + configure_and_reload_on_exit(trace: true) + assert capture_io(fn -> ExUnit.run() end) =~ "0 tests" + + defmodule EmptyGroupedParameterizedTests do + use ExUnit.Case, async: true, parameterize: [], group: :example + + test "hello world" do + assert false + end + end + + configure_and_reload_on_exit(trace: true) + assert capture_io(fn -> ExUnit.run() end) =~ "0 tests" + end + describe "after_suite/1" do test "executes all callbacks set in reverse order" do Process.register(self(), :after_suite_test_process)