@@ -716,6 +716,65 @@ defmodule Mix.Tasks.TestTest do
716716 end
717717 end
718718
719+ describe "--dry-run" do
720+ test "works with --stale" do
721+ in_fixture ( "test_stale" , fn ->
722+ File . write! ( "test/dry_run_one_test_stale.exs" , """
723+ defmodule DryRunOneTest do
724+ use ExUnit.Case
725+
726+ test "new test" do
727+ assert true
728+ end
729+ end
730+ """ )
731+
732+ File . write! ( "test/dry_run_two_test_stale.exs" , """
733+ defmodule DryRunTwoTest do
734+ use ExUnit.Case
735+
736+ @tag :skip
737+ test "skipped test" do
738+ assert true
739+ end
740+ end
741+ """ )
742+
743+ output = mix ( [ "test" , "--dry-run" , "--stale" ] )
744+ assert output =~ "Tests that would be executed:"
745+ assert output =~ "test/a_test_stale.exs:4"
746+ assert output =~ "test/b_test_stale.exs:4"
747+ assert output =~ "test/dry_run_one_test_stale.exs:4"
748+ refute output =~ "test/dry_run_two_test_stale.exs:5"
749+ assert output =~ "1 test, 0 failures, 1 skipped"
750+
751+ # Tests should still be marked as stale
752+ output = mix ( [ "test" , "--dry-run" , "--stale" ] )
753+ assert output =~ "1 test, 0 failures, 1 skipped"
754+ end )
755+ end
756+
757+ test "works with --failed" do
758+ in_fixture ( "test_failed" , fn ->
759+ output = mix ( [ "test" ] )
760+ assert output =~ "4 tests, 2 failures"
761+
762+ output = mix ( [ "test" , "--dry-run" , "--failed" ] )
763+ assert output =~ "Tests that would be executed:"
764+ assert output =~ "test/only_failing_test_failed.exs:4"
765+ assert output =~ "test/passing_and_failing_test_failed.exs:5"
766+ assert output =~ "0 tests, 0 failures"
767+
768+ # Force the tests to pass, verify dry-run doesn't actually run them
769+ System . put_env ( "PASS_FAILING_TESTS" , "true" )
770+ output = mix ( [ "test" , "--dry-run" , "--failed" ] )
771+ assert output =~ "0 tests, 0 failures"
772+ end )
773+ after
774+ System . delete_env ( "PASS_FAILING_TESTS" )
775+ end
776+ end
777+
719778 defp receive_until_match ( port , expected , acc ) do
720779 receive do
721780 { ^ port , { :data , output } } ->
0 commit comments