@@ -13,9 +13,7 @@ open Xunit.Abstractions
13
13
14
14
15
15
type AllTests ( output : ITestOutputHelper ) =
16
-
17
- [<Fact>]
18
- let ``Run all tests`` () =
16
+ let createParallelRunner () =
19
17
let myAsm = Assembly.GetExecutingAssembly()
20
18
21
19
let allMethods = [
@@ -28,13 +26,7 @@ type AllTests(output: ITestOutputHelper) =
28
26
| _ -> ()
29
27
]
30
28
31
- let x =
32
- { new System.IFormattable with
33
- member x.ToString ( format : string , provider : System.IFormatProvider ) =
34
- if format = " D" then " foo" else " bar"
35
- }
36
-
37
- task {
29
+ let all = seq {
38
30
for ( ty, method) in allMethods do
39
31
let ctor = ty.GetConstructor [| typeof< ITestOutputHelper> |]
40
32
@@ -43,14 +35,119 @@ type AllTests(output: ITestOutputHelper) =
43
35
44
36
let testObj = ctor.Invoke([| output |])
45
37
46
- let! _ =
47
- if method.ReturnType.Name.Contains " Task" then
48
- method.Invoke( testObj, null ) :?> Task < unit >
49
- else
50
- method.Invoke( testObj, null ) |> ignore
51
- task { return () }
38
+ if method.ReturnType.Name.Contains " Task" then
39
+ //task {
40
+ // let! x = Async.StartChildAsTask (Async.ofTask (method.Invoke(testObj, null) :?> Task<unit>))
41
+ // return! x
42
+ //}
43
+ async {
44
+ return !
45
+ method.Invoke( testObj, null ) :?> Task < unit >
46
+ |> Async.AwaitTask
47
+ }
48
+ else
49
+ async { return method.Invoke( testObj, null ) |> ignore }
50
+ }
52
51
53
- ()
52
+ all |> Async.Parallel |> Async.map ignore
54
53
55
- return ()
54
+ let multiply f x =
55
+ seq {
56
+ for i in [ 0 .. x ] do
57
+ yield f ()
56
58
}
59
+ |> Async.Parallel
60
+ |> Async.map ignore
61
+
62
+ [<Fact>]
63
+ let ``Run all tests 1 times in parallel`` () = task { do ! multiply createParallelRunner 1 }
64
+
65
+ [<Theory>]
66
+ [<InlineData 1 ; InlineData 2 ; InlineData 3 ; InlineData 4 ; InlineData 5 ; InlineData 6 ; InlineData 7 ; InlineData 8 >]
67
+ let ``Run all tests X times in parallel`` i = task { do ! multiply createParallelRunner i }
68
+
69
+ [<Theory>]
70
+ [<InlineData 1 ; InlineData 2 ; InlineData 3 ; InlineData 4 ; InlineData 5 ; InlineData 6 ; InlineData 7 ; InlineData 8 >]
71
+ let ``Run all tests again X times in parallel`` i = task { do ! multiply createParallelRunner i }
72
+
73
+ [<Theory>]
74
+ [<InlineData 1 ; InlineData 2 ; InlineData 3 ; InlineData 4 ; InlineData 5 ; InlineData 6 ; InlineData 7 ; InlineData 8 >]
75
+ let ``Run all tests and once more , X times in parallel`` i = task { do ! multiply createParallelRunner i }
76
+
77
+
78
+ //[<Fact>]
79
+ //let ``Run all tests 3 times in parallel`` () =
80
+ // multiply createParallelRunner 15
81
+ // |> Async.RunSynchronously
82
+
83
+
84
+ //[<Fact>]
85
+ //let ``Run all tests 4 times in parallel`` () =
86
+ // multiply createParallelRunner 15
87
+ // |> Async.RunSynchronously
88
+
89
+
90
+ //[<Fact>]
91
+ //let ``Run all tests 5 times in parallel`` () =
92
+ // multiply createParallelRunner 15
93
+ // |> Async.RunSynchronously
94
+
95
+
96
+ //[<Fact>]
97
+ //let ``Run all tests 6 times in parallel`` () =
98
+ // multiply createParallelRunner 15
99
+ // |> Async.RunSynchronously
100
+
101
+
102
+ //[<Fact>]
103
+ //let ``Run all tests 7 times in parallel`` () =
104
+ // multiply createParallelRunner 15
105
+ // |> Async.RunSynchronously
106
+
107
+
108
+ //[<Fact>]
109
+ //let ``Run all tests 8 times in parallel`` () =
110
+ // multiply createParallelRunner 15
111
+ // |> Async.RunSynchronously
112
+
113
+
114
+ //[<Fact>]
115
+ //let ``Run all tests 9 times in parallel`` () =
116
+ // multiply createParallelRunner 15
117
+ // |> Async.RunSynchronously
118
+
119
+
120
+ //[<Fact>]
121
+ //let ``Run all tests 10 times in parallel`` () =
122
+ // multiply createParallelRunner 15
123
+ // |> Async.RunSynchronously
124
+
125
+
126
+ //[<Fact>]
127
+ //let ``Run all tests 11 times in parallel`` () =
128
+ // multiply createParallelRunner 15
129
+ // |> Async.RunSynchronously
130
+
131
+
132
+ //[<Fact>]
133
+ //let ``Run all tests 12 times in parallel`` () =
134
+ // multiply createParallelRunner 15
135
+ // |> Async.RunSynchronously
136
+
137
+
138
+ //[<Fact>]
139
+ //let ``Run all tests 13 times in parallel`` () =
140
+ // multiply createParallelRunner 15
141
+ // |> Async.RunSynchronously
142
+
143
+
144
+ //[<Fact>]
145
+ //let ``Run all tests 14 times in parallel`` () =
146
+ // multiply createParallelRunner 15
147
+ // |> Async.RunSynchronously
148
+
149
+
150
+ //[<Fact>]
151
+ //let ``Run all tests 15 times in parallel`` () =
152
+ // multiply createParallelRunner 15
153
+ // |> Async.RunSynchronously
0 commit comments