@@ -1101,10 +1101,50 @@ defmodule ExUnitTest do
1101
1101
assert third =~ "ThirdTestFIFO"
1102
1102
end
1103
1103
1104
+ test "can filter async tests" do
1105
+ defmodule FirstTestAsyncTrue do
1106
+ use ExUnit.Case , async: true
1107
+
1108
+ test "first test" do
1109
+ assert true
1110
+ end
1111
+ end
1112
+
1113
+ defmodule SecondTestAsyncTrue do
1114
+ use ExUnit.Case , async: true
1115
+
1116
+ test "second test" do
1117
+ assert true
1118
+ end
1119
+ end
1120
+
1121
+ defmodule FirstTestAsyncFalse do
1122
+ use ExUnit.Case , async: false
1123
+
1124
+ test "first test" do
1125
+ assert true
1126
+ end
1127
+ end
1128
+
1129
+ assert { % { failures: 0 , skipped: 0 , total: 3 , excluded: 1 } , _ } =
1130
+ run_with_filter ( [ include: [ async: true ] , exclude: [ :test ] ] , [ ] )
1131
+
1132
+ assert { % { failures: 0 , skipped: 0 , total: 3 , excluded: 2 } , _ } =
1133
+ run_with_filter ( [ include: [ async: false ] , exclude: [ :test ] ] , [
1134
+ FirstTestAsyncTrue ,
1135
+ SecondTestAsyncTrue ,
1136
+ FirstTestAsyncFalse
1137
+ ] )
1138
+ end
1139
+
1104
1140
## Helpers
1105
1141
1106
1142
defp run_with_filter ( filters , cases ) do
1107
- Enum . each ( cases , & ExUnit.Server . add_module ( & 1 , { false , nil } ) )
1143
+ Enum . each ( cases , fn mod ->
1144
+ [ config ] = mod . __info__ ( :attributes ) |> Keyword . fetch! ( :ex_unit_module )
1145
+ ExUnit.Server . add_module ( mod , config )
1146
+ end )
1147
+
1108
1148
ExUnit.Server . modules_loaded ( false )
1109
1149
1110
1150
opts =
0 commit comments