diff --git a/lib/mix/test/mix/cli_test.exs b/lib/mix/test/mix/cli_test.exs index 71dceae495d..a46fae6c6e8 100644 --- a/lib/mix/test/mix/cli_test.exs +++ b/lib/mix/test/mix/cli_test.exs @@ -253,7 +253,7 @@ defmodule Mix.CLITest do output = mix(~w[test test/new_with_tests_test.exs --cover]) assert File.regular?("_build/test/lib/new_with_tests/ebin/Elixir.NewWithTests.beam") - assert output =~ "1 doctest, 1 test, 0 failures" + assert output =~ "Passed: 2 (1 doctest, 1 test)" assert output =~ "Generating cover results ..." assert File.regular?("cover/Elixir.NewWithTests.html") end) @@ -267,7 +267,7 @@ defmodule Mix.CLITest do output = mix(~w[test]) assert File.regular?("_build/test/lib/sup_with_tests/ebin/Elixir.SupWithTests.beam") - assert output =~ "1 doctest, 1 test, 0 failures" + assert output =~ "Passed: 2 (1 doctest, 1 test)" end) end end diff --git a/lib/mix/test/mix/tasks/test_test.exs b/lib/mix/test/mix/tasks/test_test.exs index 58de9b0f08a..bb1385197bf 100644 --- a/lib/mix/test/mix/tasks/test_test.exs +++ b/lib/mix/test/mix/tasks/test_test.exs @@ -74,7 +74,7 @@ defmodule Mix.Tasks.TestTest do describe "--stale" do test "runs all tests for first run, then none on second" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") assert_stale_run_output(""" No stale tests @@ -84,23 +84,23 @@ defmodule Mix.Tasks.TestTest do test "runs tests that depend on modified modules" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") set_all_mtimes() force_recompilation("lib/b.ex") - assert_stale_run_output("1 test, 0 failures") + assert_stale_run_output("Passed: 1") set_all_mtimes() force_recompilation("lib/a.ex") - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") end) end test "doesn't write manifest when there are failures" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") set_all_mtimes() @@ -110,39 +110,39 @@ defmodule Mix.Tasks.TestTest do end """) - assert_stale_run_output("1 test, 1 failure") + assert_stale_run_output("Failed: 1 test") - assert_stale_run_output("1 test, 1 failure") + assert_stale_run_output("Failed: 1 test") end) end test "runs tests that have changed" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") set_all_mtimes() File.touch!("test/a_test_stale.exs") - assert_stale_run_output("1 test, 0 failures") + assert_stale_run_output("Passed: 1") end) end test "runs tests that have changed test_helpers" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") set_all_mtimes() File.touch!("test/test_helper.exs") - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") end) end test "runs all tests no matter what with --force" do in_fixture("test_stale", fn -> - assert_stale_run_output("2 tests, 0 failures") + assert_stale_run_output("Passed: 2") - assert_stale_run_output(~w[--force], "2 tests, 0 failures") + assert_stale_run_output(~w[--force], "Passed: 2") end) end end @@ -154,7 +154,7 @@ defmodule Mix.Tasks.TestTest do # This fixture by default results in coverage above the default threshold # which should result in an exit status of 0. assert {output, 0} = mix_code(["test", "--cover"]) - assert output =~ "4 tests, 0 failures" + assert output =~ "Passed: 4" # For bar, we do regular --cover and also test protocols assert output =~ """ @@ -168,7 +168,7 @@ defmodule Mix.Tasks.TestTest do | 100.00% | Total | """ - assert output =~ "1 test, 0 failures" + assert output =~ "Passed: 1" # For foo, we do regular --cover and test it does not include bar assert output =~ """ @@ -227,24 +227,24 @@ defmodule Mix.Tasks.TestTest do # Run `mix test` once to record failures... output = mix(["test"]) assert output =~ loading_only_passing_test_msg - assert output =~ "4 tests, 2 failures" + assert output =~ "Failed: 2 tests" # `mix test --failed` runs only failed tests and avoids loading files with no failures output = mix(["test", "--failed"]) refute output =~ loading_only_passing_test_msg - assert output =~ "2 tests, 2 failures" + assert output =~ "Failed: 2 tests" # `mix test --failed` can be applied to a directory or file output = mix(["test", "test/passing_and_failing_test_failed.exs", "--failed"]) - assert output =~ "1 test, 1 failure" + assert output =~ "Failed: 1 test" # Plus line output = mix(["test", "test/passing_and_failing_test_failed.exs:5", "--failed"]) - assert output =~ "1 test, 1 failure" + assert output =~ "Failed: 1 test" if windows?() do output = mix(["test", "test\\passing_and_failing_test_failed.exs:5", "--failed"]) - assert output =~ "1 test, 1 failure" + assert output =~ "Failed: 1 test" end # `--failed` composes with an `--only` filter by running the intersection. @@ -252,11 +252,11 @@ defmodule Mix.Tasks.TestTest do # Of the passing tests, 1 is tagged with `@tag :foo`. # But only the failing test with that tag should run. output = mix(["test", "--failed", "--only", "foo"]) - assert output =~ "1 test, 1 failure (1 excluded)" + assert output =~ "Failed: 1 test" # Run again to give it a chance to record as passed System.put_env("PASS_FAILING_TESTS", "true") - assert mix(["test", "--failed"]) =~ "2 tests, 0 failures" + assert mix(["test", "--failed"]) =~ "Passed: 2" # Nothing should get run if we try it again since everything is passing. assert mix(["test", "--failed"]) =~ "There are no tests to run" @@ -292,7 +292,7 @@ defmodule Mix.Tasks.TestTest do in_fixture("test_stale", fn -> port = mix_port(~w[test --stale --listen-on-stdin]) - assert receive_until_match(port, "0 failures", "") =~ "2 tests" + assert receive_until_match(port, "Passed:", "") =~ "Passed: 2" Port.command(port, "\n") @@ -306,10 +306,10 @@ defmodule Mix.Tasks.TestTest do test "splits tests into partitions (with coverage)" do in_fixture("test_stale", fn -> assert mix(["test", "--partitions", "3", "--cover"], [{"MIX_TEST_PARTITION", "1"}]) =~ - "1 test, 0 failures" + "Passed: 1" assert mix(["test", "--partitions", "3", "--cover"], [{"MIX_TEST_PARTITION", "2"}]) =~ - "1 test, 0 failures" + "Passed: 1" assert mix(["test", "--partitions", "3", "--cover"], [{"MIX_TEST_PARTITION", "3"}]) =~ "There are no tests to run" @@ -351,13 +351,13 @@ defmodule Mix.Tasks.TestTest do test "do not raise if partitions flag is set to 1 and no partition given" do in_fixture("test_stale", fn -> assert mix(["test", "--partitions", "1"], []) =~ - "2 tests, 0 failures" + "Passed: 2" assert mix(["test", "--partitions", "1"], [{"MIX_TEST_PARTITION", ""}]) =~ - "2 tests, 0 failures" + "Passed: 2" assert mix(["test", "--partitions", "1"], [{"MIX_TEST_PARTITION", "1"}]) =~ - "2 tests, 0 failures" + "Passed: 2" end) end @@ -501,14 +501,14 @@ defmodule Mix.Tasks.TestTest do Including tags: [location: {"test/foo_tests.exs", 9}] """ - assert output =~ "1 test, 0 failures\n" + assert output =~ "Passed: 1\n" assert output =~ """ Excluding tags: [:test] Including tags: [location: {"test/bar_tests.exs", 5}] """ - assert output =~ "1 test, 0 failures (3 excluded)\n" + assert output =~ "Passed: 1 (3 excluded)\n" end) end end @@ -568,7 +568,7 @@ defmodule Mix.Tasks.TestTest do ]) assert output =~ "variable \"unused_test_var\" is unused" - assert output =~ "1 failure" + assert output =~ "Failed: 1 test" assert exit_status == 43 end) @@ -587,10 +587,10 @@ defmodule Mix.Tasks.TestTest do """) output = mix(["test", "--warnings-as-errors"]) - assert output =~ "2 failures" + assert output =~ "Failed: 2 tests" refute output =~ "Test suite aborted after successful execution" output = mix(["test", "--failed"]) - assert output =~ "2 failures" + assert output =~ "Failed: 2 tests" end) end @@ -618,7 +618,7 @@ defmodule Mix.Tasks.TestTest do test "returns custom exit status" do in_fixture("test_failed", fn -> {output, exit_status} = mix_code(["test", "--exit-status", "5"]) - assert output =~ "2 failures" + assert output =~ "Failed: 2 tests" assert exit_status == 5 end) end @@ -630,7 +630,7 @@ defmodule Mix.Tasks.TestTest do # it does not test the concurrency behavior in_fixture("test_stale", fn -> output = mix(["test", "--max-requires", "1"]) - assert output =~ "0 failures" + assert output =~ "Passed:" end) end end @@ -695,7 +695,7 @@ defmodule Mix.Tasks.TestTest do """ # the dummy test ran successfully - assert output =~ "1 test, 0 failures" + assert output =~ "Passed: 1" end) end @@ -740,7 +740,7 @@ defmodule Mix.Tasks.TestTest do refute output =~ "the following files do not match" # the dummy test ran successfully - assert output =~ "1 test, 0 failures" + assert output =~ "Passed: 1" end) end end @@ -775,29 +775,31 @@ defmodule Mix.Tasks.TestTest do assert output =~ "test/b_test_stale.exs:4" assert output =~ "test/dry_run_one_test_stale.exs:4" refute output =~ "test/dry_run_two_test_stale.exs:5" - assert output =~ "1 test, 0 failures, 1 skipped" + assert output =~ "1 skipped" + assert output =~ "Passed:" # Tests should still be marked as stale output = mix(["test", "--dry-run", "--stale"]) - assert output =~ "1 test, 0 failures, 1 skipped" + assert output =~ "1 skipped" + assert output =~ "Passed:" end) end test "works with --failed" do in_fixture("test_failed", fn -> output = mix(["test"]) - assert output =~ "4 tests, 2 failures" + assert output =~ "Failed: 2 tests" output = mix(["test", "--dry-run", "--failed"]) assert output =~ "Tests that would be executed:" assert output =~ "test/only_failing_test_failed.exs:4" assert output =~ "test/passing_and_failing_test_failed.exs:5" - assert output =~ "0 tests, 0 failures" + assert output =~ "Passed: 0" # Force the tests to pass, verify dry-run doesn't actually run them System.put_env("PASS_FAILING_TESTS", "true") output = mix(["test", "--dry-run", "--failed"]) - assert output =~ "0 tests, 0 failures" + assert output =~ "Passed: 0" end) after System.delete_env("PASS_FAILING_TESTS")