@@ -1018,21 +1018,36 @@ defmodule ExUnitTest do
10181018 end
10191019
10201020 test "repeats tests up to the configured number of times" do
1021- defmodule TestRepeatUntilFailureReached do
1022- use ExUnit.Case
1021+ { :ok , agent } =
1022+ Agent . start_link ( fn -> [ ] end , name: :ex_unit_repeat_until_failure_async_order )
1023+
1024+ defmodule TestRepeatUntilFailureReachedOne do
1025+ use ExUnit.Case , async: true
10231026
10241027 @ tag :skip
10251028 test "skipped #{ __ENV__ . line } " , do: assert ( false )
10261029
1027- test __ENV__ . line , do: assert ( true )
1028- test __ENV__ . line , do: assert ( true )
1029- test __ENV__ . line , do: assert ( true )
1030+ test __ENV__ . line do
1031+ Agent . update ( :ex_unit_repeat_until_failure_async_order , & [ __MODULE__ | & 1 ] )
1032+ end
1033+
1034+ test __ENV__ . line do
1035+ Agent . update ( :ex_unit_repeat_until_failure_async_order , & [ __MODULE__ | & 1 ] )
1036+ end
10301037
10311038 @ tag :exclude
10321039 test "excluded #{ __ENV__ . line } " , do: assert ( false )
10331040 end
10341041
1035- configure_and_reload_on_exit ( repeat_until_failure: 5 )
1042+ defmodule TestRepeatUntilFailureReachedTwo do
1043+ use ExUnit.Case , async: true
1044+
1045+ test __ENV__ . line do
1046+ Agent . update ( :ex_unit_repeat_until_failure_async_order , & [ __MODULE__ | & 1 ] )
1047+ end
1048+ end
1049+
1050+ configure_and_reload_on_exit ( repeat_until_failure: 5 , max_cases: 1 )
10361051
10371052 output =
10381053 capture_io ( fn ->
@@ -1044,26 +1059,66 @@ defmodule ExUnitTest do
10441059 assert length ( runs ) == 6
10451060 assert output =~ "remaining_runs: 5"
10461061 assert output =~ "remaining_runs: 0"
1062+
1063+ assert Agent . get ( agent , & Enum . reverse / 1 ) ==
1064+ List . duplicate (
1065+ [
1066+ TestRepeatUntilFailureReachedOne ,
1067+ TestRepeatUntilFailureReachedOne ,
1068+ TestRepeatUntilFailureReachedTwo
1069+ ] ,
1070+ 6
1071+ )
1072+ |> List . flatten ( )
10471073 end
10481074
10491075 test "repeats tests up to the configured number of times with groups" do
1050- defmodule TestGroupedRepeatUntilFailureReached do
1076+ { :ok , agent } =
1077+ Agent . start_link ( fn -> [ ] end , name: :ex_unit_repeat_until_failure_group_order )
1078+
1079+ defmodule TestGroupedRepeatUntilFailureReachedOne do
10511080 use ExUnit.Case , async: true , group: :example
1052- test __ENV__ . line , do: assert ( true )
1081+
1082+ test __ENV__ . line do
1083+ Agent . update ( :ex_unit_repeat_until_failure_group_order , & [ __MODULE__ | & 1 ] )
1084+ end
10531085 end
10541086
1055- configure_and_reload_on_exit ( repeat_until_failure: 5 )
1087+ defmodule TestGroupedRepeatUntilFailureReachedTwo do
1088+ use ExUnit.Case , async: true , group: :example
1089+
1090+ test __ENV__ . line do
1091+ Agent . update ( :ex_unit_repeat_until_failure_group_order , & [ __MODULE__ | & 1 ] )
1092+ end
1093+ end
1094+
1095+ configure_and_reload_on_exit ( repeat_until_failure: 5 , max_cases: 1 )
10561096
10571097 output =
10581098 capture_io ( fn ->
1059- assert ExUnit . run ( ) == % { total: 1 , failures: 0 , skipped: 0 , excluded: 0 }
1099+ assert ExUnit . run ( ) == % { total: 2 , failures: 0 , skipped: 0 , excluded: 0 }
10601100 end )
10611101
10621102 runs = String . split ( output , "Running ExUnit" , trim: true )
10631103 # 6 runs in total, 5 repeats
10641104 assert length ( runs ) == 6
10651105 assert output =~ "remaining_runs: 5"
10661106 assert output =~ "remaining_runs: 0"
1107+
1108+ assert Agent . get ( agent , & Enum . reverse / 1 ) == [
1109+ TestGroupedRepeatUntilFailureReachedOne ,
1110+ TestGroupedRepeatUntilFailureReachedTwo ,
1111+ TestGroupedRepeatUntilFailureReachedOne ,
1112+ TestGroupedRepeatUntilFailureReachedTwo ,
1113+ TestGroupedRepeatUntilFailureReachedOne ,
1114+ TestGroupedRepeatUntilFailureReachedTwo ,
1115+ TestGroupedRepeatUntilFailureReachedOne ,
1116+ TestGroupedRepeatUntilFailureReachedTwo ,
1117+ TestGroupedRepeatUntilFailureReachedOne ,
1118+ TestGroupedRepeatUntilFailureReachedTwo ,
1119+ TestGroupedRepeatUntilFailureReachedOne ,
1120+ TestGroupedRepeatUntilFailureReachedTwo
1121+ ]
10671122 end
10681123
10691124 test "stops on failure" do
0 commit comments