Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions lib/ex_unit/lib/ex_unit/cli_formatter.ex
Original file line number Diff line number Diff line change
Expand Up @@ -384,15 +384,21 @@ defmodule ExUnit.CLIFormatter do
IO.puts(formatted)
end

defp format_test_type_counts(%{test_counter: test_counter} = _config) do
test_counter
defp format_test_type_counts(config) do
config.test_counter
|> Enum.sort()
|> Enum.map(fn {test_type, count} ->
type_pluralized = pluralize(count, test_type, ExUnit.plural_rule(test_type |> to_string()))
"#{count} #{type_pluralized}, "
executed_count = calculate_executed_test_count(test_type, count, config.excluded_counter)
plural_rule = ExUnit.plural_rule(test_type |> to_string())
type_pluralized = pluralize(executed_count, test_type, plural_rule)

"#{executed_count} #{type_pluralized}, "
end)
end

defp calculate_executed_test_count(:test, count, excluded_counter), do: count - excluded_counter
defp calculate_executed_test_count(_test_type, count, _excluded_counter), do: count

defp collect_test_type_counts(%{test_counter: test_counter} = _config) do
Enum.reduce(test_counter, 0, fn {_, count}, acc ->
acc + count
Expand Down
24 changes: 12 additions & 12 deletions lib/ex_unit/test/ex_unit_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -331,19 +331,19 @@ defmodule ExUnitTest do

{result, output} = run_with_filter([exclude: [even: true]], [ParityTest])
assert result == %{failures: 0, skipped: 0, excluded: 1, total: 4}
assert output =~ "\n4 tests, 0 failures, 1 excluded\n"
assert output =~ "\n3 tests, 0 failures, 1 excluded\n"

{result, output} = run_with_filter([exclude: :even], [ParityTest])
assert result == %{failures: 0, skipped: 0, excluded: 3, total: 4}
assert output =~ "\n4 tests, 0 failures, 3 excluded\n"
assert output =~ "\n1 test, 0 failures, 3 excluded\n"

{result, output} = run_with_filter([exclude: :even, include: [even: true]], [ParityTest])
assert result == %{failures: 1, skipped: 0, excluded: 2, total: 4}
assert output =~ "\n4 tests, 1 failure, 2 excluded\n"
assert output =~ "\n2 tests, 1 failure, 2 excluded\n"

{result, output} = run_with_filter([exclude: :test, include: [even: true]], [ParityTest])
assert result == %{failures: 1, skipped: 0, excluded: 3, total: 4}
assert output =~ "\n4 tests, 1 failure, 3 excluded\n"
assert output =~ "\n1 test, 1 failure, 3 excluded\n"
end

test "log capturing" do
Expand Down Expand Up @@ -509,15 +509,15 @@ defmodule ExUnitTest do
# Empty because it is already loaded
{result, output} = run_with_filter([exclude: :module], [])
assert result == %{failures: 0, skipped: 0, excluded: 2, total: 2}
assert output =~ "\n2 tests, 0 failures, 2 excluded\n"
assert output =~ "\n0 tests, 0 failures, 2 excluded\n"

{result, output} =
[exclude: :test, include: [module: "ExUnitTest.SecondTestModule"]]
|> run_with_filter([FirstTestModule, SecondTestModule])

assert result == %{failures: 1, skipped: 0, excluded: 1, total: 2}
assert output =~ "\n 1) test false (ExUnitTest.SecondTestModule)\n"
assert output =~ "\n2 tests, 1 failure, 1 excluded\n"
assert output =~ "\n1 test, 1 failure, 1 excluded\n"
end

test "raises on reserved tag :file in module" do
Expand Down Expand Up @@ -680,7 +680,7 @@ defmodule ExUnitTest do
end)

refute output =~ max_failures_reached_msg()
assert output =~ "\n6 tests, 0 failures, 1 excluded, 4 invalid, 1 skipped\n"
assert output =~ "\n5 tests, 0 failures, 1 excluded, 4 invalid, 1 skipped\n"
end

test "parameterized tests" do
Expand Down Expand Up @@ -787,7 +787,7 @@ defmodule ExUnitTest do
end)

assert output =~ max_failures_reached_msg()
assert output =~ "\n6 tests, 2 failures, 1 excluded, 1 skipped\n"
assert output =~ "\n5 tests, 2 failures, 1 excluded, 1 skipped\n"
end

test ":max_failures is not reached" do
Expand Down Expand Up @@ -818,7 +818,7 @@ defmodule ExUnitTest do
end)

refute output =~ max_failures_reached_msg()
assert output =~ "\n8 tests, 2 failures, 2 excluded, 1 skipped\n"
assert output =~ "\n6 tests, 2 failures, 2 excluded, 1 skipped\n"
end

test ":max_failures has been reached" do
Expand Down Expand Up @@ -852,7 +852,7 @@ defmodule ExUnitTest do
end)

assert output =~ max_failures_reached_msg()
assert output =~ "\n7 tests, 2 failures, 2 excluded, 2 skipped\n"
assert output =~ "\n5 tests, 2 failures, 2 excluded, 2 skipped\n"
end

# Excluded and skipped tests are detected before setup_all
Expand Down Expand Up @@ -886,7 +886,7 @@ defmodule ExUnitTest do
end)

assert output =~ max_failures_reached_msg()
assert output =~ "\n4 tests, 0 failures, 1 excluded, 2 invalid, 1 skipped\n"
assert output =~ "\n3 tests, 0 failures, 1 excluded, 2 invalid, 1 skipped\n"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I have one last nitpick. In this large list, we have excluded, invalid, and skipped, and it is hard to know which ones are counted as tests. I think we should either move "excluded" as the last one or perhaps show it in parens, such as "1 skipped (1 excluded)". WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't be sorry! I appreciate the patience (:

I tried both locally and I think moving it to the last of the list reads the best. I'll push that up shortly and see what you think!

end

test ":max_failures flushes all async/sync cases" do
Expand Down Expand Up @@ -1059,7 +1059,7 @@ defmodule ExUnitTest do
end)

assert output =~ "All tests have been excluded.\n"
assert output =~ "2 tests, 0 failures, 2 excluded\n"
assert output =~ "0 tests, 0 failures, 2 excluded\n"
end

test "tests are run in compile order (FIFO)" do
Expand Down
Loading