OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 @TestOn("vm") | 5 @TestOn("vm") |
6 | 6 |
7 import 'dart:convert'; | 7 import 'dart:convert'; |
8 | 8 |
9 import 'package:scheduled_test/descriptor.dart' as d; | 9 import 'package:scheduled_test/descriptor.dart' as d; |
10 import 'package:scheduled_test/scheduled_stream.dart'; | 10 import 'package:scheduled_test/scheduled_stream.dart'; |
(...skipping 13 matching lines...) Expand all Loading... |
24 void main() { | 24 void main() { |
25 useSandbox(); | 25 useSandbox(); |
26 | 26 |
27 test("runs several successful tests and reports when each completes", () { | 27 test("runs several successful tests and reports when each completes", () { |
28 _expectReport(""" | 28 _expectReport(""" |
29 test('success 1', () {}); | 29 test('success 1', () {}); |
30 test('success 2', () {}); | 30 test('success 2', () {}); |
31 test('success 3', () {}); | 31 test('success 3', () {}); |
32 """, [ | 32 """, [ |
33 _start, | 33 _start, |
34 _testStart(0, "loading test.dart"), | 34 _testStart(0, "loading test.dart", groupIDs: []), |
35 _testDone(0, hidden: true), | 35 _testDone(0, hidden: true), |
36 _testStart(1, "success 1"), | 36 _group(1), |
37 _testDone(1), | 37 _testStart(2, "success 1"), |
38 _testStart(2, "success 2"), | |
39 _testDone(2), | 38 _testDone(2), |
40 _testStart(3, "success 3"), | 39 _testStart(3, "success 2"), |
41 _testDone(3), | 40 _testDone(3), |
| 41 _testStart(4, "success 3"), |
| 42 _testDone(4), |
42 _done() | 43 _done() |
43 ]); | 44 ]); |
44 }); | 45 }); |
45 | 46 |
46 test("runs several failing tests and reports when each fails", () { | 47 test("runs several failing tests and reports when each fails", () { |
47 _expectReport(""" | 48 _expectReport(""" |
48 test('failure 1', () => throw new TestFailure('oh no')); | 49 test('failure 1', () => throw new TestFailure('oh no')); |
49 test('failure 2', () => throw new TestFailure('oh no')); | 50 test('failure 2', () => throw new TestFailure('oh no')); |
50 test('failure 3', () => throw new TestFailure('oh no')); | 51 test('failure 3', () => throw new TestFailure('oh no')); |
51 """, [ | 52 """, [ |
52 _start, | 53 _start, |
53 _testStart(0, "loading test.dart"), | 54 _testStart(0, "loading test.dart", groupIDs: []), |
54 _testDone(0, hidden: true), | 55 _testDone(0, hidden: true), |
55 _testStart(1, "failure 1"), | 56 _group(1), |
56 _error(1, "oh no", isFailure: true), | 57 _testStart(2, "failure 1"), |
57 _testDone(1, result: "failure"), | |
58 _testStart(2, "failure 2"), | |
59 _error(2, "oh no", isFailure: true), | 58 _error(2, "oh no", isFailure: true), |
60 _testDone(2, result: "failure"), | 59 _testDone(2, result: "failure"), |
61 _testStart(3, "failure 3"), | 60 _testStart(3, "failure 2"), |
62 _error(3, "oh no", isFailure: true), | 61 _error(3, "oh no", isFailure: true), |
63 _testDone(3, result: "failure"), | 62 _testDone(3, result: "failure"), |
| 63 _testStart(4, "failure 3"), |
| 64 _error(4, "oh no", isFailure: true), |
| 65 _testDone(4, result: "failure"), |
64 _done(success: false) | 66 _done(success: false) |
65 ]); | 67 ]); |
66 }); | 68 }); |
67 | 69 |
68 test("includes the full stack trace with --verbose-trace", () { | 70 test("includes the full stack trace with --verbose-trace", () { |
69 d.file("test.dart", """ | 71 d.file("test.dart", """ |
70 import 'dart:async'; | 72 import 'dart:async'; |
71 | 73 |
72 import 'package:test/test.dart'; | 74 import 'package:test/test.dart'; |
73 | 75 |
74 void main() { | 76 void main() { |
75 test("failure", () => throw "oh no"); | 77 test("failure", () => throw "oh no"); |
76 } | 78 } |
77 """).create(); | 79 """).create(); |
78 | 80 |
79 var test = runTest(["--verbose-trace", "test.dart"], reporter: "json"); | 81 var test = runTest(["--verbose-trace", "test.dart"], reporter: "json"); |
80 test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); | 82 test.stdout.expect(consumeThrough(contains("dart:isolate-patch"))); |
81 test.shouldExit(1); | 83 test.shouldExit(1); |
82 }); | 84 }); |
83 | 85 |
84 test("runs failing tests along with successful tests", () { | 86 test("runs failing tests along with successful tests", () { |
85 _expectReport(""" | 87 _expectReport(""" |
86 test('failure 1', () => throw new TestFailure('oh no')); | 88 test('failure 1', () => throw new TestFailure('oh no')); |
87 test('success 1', () {}); | 89 test('success 1', () {}); |
88 test('failure 2', () => throw new TestFailure('oh no')); | 90 test('failure 2', () => throw new TestFailure('oh no')); |
89 test('success 2', () {}); | 91 test('success 2', () {}); |
90 """, [ | 92 """, [ |
91 _start, | 93 _start, |
92 _testStart(0, "loading test.dart"), | 94 _testStart(0, "loading test.dart", groupIDs: []), |
93 _testDone(0, hidden: true), | 95 _testDone(0, hidden: true), |
94 _testStart(1, "failure 1"), | 96 _group(1), |
95 _error(1, "oh no", isFailure: true), | 97 _testStart(2, "failure 1"), |
96 _testDone(1, result: "failure"), | 98 _error(2, "oh no", isFailure: true), |
97 _testStart(2, "success 1"), | 99 _testDone(2, result: "failure"), |
98 _testDone(2), | 100 _testStart(3, "success 1"), |
99 _testStart(3, "failure 2"), | 101 _testDone(3), |
100 _error(3, "oh no", isFailure: true), | 102 _testStart(4, "failure 2"), |
101 _testDone(3, result: "failure"), | 103 _error(4, "oh no", isFailure: true), |
102 _testStart(4, "success 2"), | 104 _testDone(4, result: "failure"), |
103 _testDone(4), | 105 _testStart(5, "success 2"), |
| 106 _testDone(5), |
104 _done(success: false) | 107 _done(success: false) |
105 ]); | 108 ]); |
106 }); | 109 }); |
107 | 110 |
108 test("gracefully handles multiple test failures in a row", () { | 111 test("gracefully handles multiple test failures in a row", () { |
109 _expectReport(""" | 112 _expectReport(""" |
110 // This completer ensures that the test isolate isn't killed until all | 113 // This completer ensures that the test isolate isn't killed until all |
111 // errors have been thrown. | 114 // errors have been thrown. |
112 var completer = new Completer(); | 115 var completer = new Completer(); |
113 test('failures', () { | 116 test('failures', () { |
114 new Future.microtask(() => throw 'first error'); | 117 new Future.microtask(() => throw 'first error'); |
115 new Future.microtask(() => throw 'second error'); | 118 new Future.microtask(() => throw 'second error'); |
116 new Future.microtask(() => throw 'third error'); | 119 new Future.microtask(() => throw 'third error'); |
117 new Future.microtask(completer.complete); | 120 new Future.microtask(completer.complete); |
118 }); | 121 }); |
119 test('wait', () => completer.future); | 122 test('wait', () => completer.future); |
120 """, [ | 123 """, [ |
121 _start, | 124 _start, |
122 _testStart(0, "loading test.dart"), | 125 _testStart(0, "loading test.dart", groupIDs: []), |
123 _testDone(0, hidden: true), | 126 _testDone(0, hidden: true), |
124 _testStart(1, "failures"), | 127 _group(1), |
125 _error(1, "first error"), | 128 _testStart(2, "failures"), |
126 _error(1, "second error"), | 129 _error(2, "first error"), |
127 _error(1, "third error"), | 130 _error(2, "second error"), |
128 _testDone(1, result: "error"), | 131 _error(2, "third error"), |
129 _testStart(2, "wait"), | 132 _testDone(2, result: "error"), |
130 _testDone(2), | 133 _testStart(3, "wait"), |
| 134 _testDone(3), |
131 _done(success: false) | 135 _done(success: false) |
132 ]); | 136 ]); |
133 }); | 137 }); |
134 | 138 |
135 test("gracefully handles a test failing after completion", () { | 139 test("gracefully handles a test failing after completion", () { |
136 _expectReport(""" | 140 _expectReport(""" |
137 // These completers ensure that the first test won't fail until the second | 141 // These completers ensure that the first test won't fail until the second |
138 // one is running, and that the test isolate isn't killed until all errors | 142 // one is running, and that the test isolate isn't killed until all errors |
139 // have been thrown. | 143 // have been thrown. |
140 var waitStarted = new Completer(); | 144 var waitStarted = new Completer(); |
141 var testDone = new Completer(); | 145 var testDone = new Completer(); |
142 test('failure', () { | 146 test('failure', () { |
143 waitStarted.future.then((_) { | 147 waitStarted.future.then((_) { |
144 new Future.microtask(testDone.complete); | 148 new Future.microtask(testDone.complete); |
145 throw 'oh no'; | 149 throw 'oh no'; |
146 }); | 150 }); |
147 }); | 151 }); |
148 test('wait', () { | 152 test('wait', () { |
149 waitStarted.complete(); | 153 waitStarted.complete(); |
150 return testDone.future; | 154 return testDone.future; |
151 }); | 155 }); |
152 """, [ | 156 """, [ |
153 _start, | 157 _start, |
154 _testStart(0, "loading test.dart"), | 158 _testStart(0, "loading test.dart", groupIDs: []), |
155 _testDone(0, hidden: true), | 159 _testDone(0, hidden: true), |
156 _testStart(1, "failure"), | 160 _group(1), |
157 _testDone(1), | 161 _testStart(2, "failure"), |
158 _testStart(2, "wait"), | 162 _testDone(2), |
159 _error(1, "oh no"), | 163 _testStart(3, "wait"), |
160 _error(1, | 164 _error(2, "oh no"), |
| 165 _error(2, |
161 "This test failed after it had already completed. Make sure to " | 166 "This test failed after it had already completed. Make sure to " |
162 "use [expectAsync]\n" | 167 "use [expectAsync]\n" |
163 "or the [completes] matcher when testing async code."), | 168 "or the [completes] matcher when testing async code."), |
164 _testDone(2), | 169 _testDone(3), |
165 _done(success: false) | 170 _done(success: false) |
166 ]); | 171 ]); |
167 }); | 172 }); |
168 | 173 |
| 174 test("reports each test in its proper groups", () { |
| 175 _expectReport(""" |
| 176 group('group 1', () { |
| 177 group('.2', () { |
| 178 group('.3', () { |
| 179 test('success', () {}); |
| 180 }); |
| 181 }); |
| 182 |
| 183 test('success', () {}); |
| 184 test('success', () {}); |
| 185 }); |
| 186 """, [ |
| 187 _start, |
| 188 _testStart(0, "loading test.dart", groupIDs: []), |
| 189 _testDone(0, hidden: true), |
| 190 _group(1), |
| 191 _group(2, name: "group 1", parentID: 1), |
| 192 _group(3, name: "group 1 .2", parentID: 2), |
| 193 _group(4, name: "group 1 .2 .3", parentID: 3), |
| 194 _testStart(5, 'group 1 .2 .3 success', groupIDs: [1, 2, 3, 4]), |
| 195 _testDone(5), |
| 196 _testStart(6, 'group 1 success', groupIDs: [1, 2]), |
| 197 _testDone(6), |
| 198 _testStart(7, 'group 1 success', groupIDs: [1, 2]), |
| 199 _testDone(7), |
| 200 _done() |
| 201 ]); |
| 202 }); |
| 203 |
169 group("print:", () { | 204 group("print:", () { |
170 test("handles multiple prints", () { | 205 test("handles multiple prints", () { |
171 _expectReport(""" | 206 _expectReport(""" |
172 test('test', () { | 207 test('test', () { |
173 print("one"); | 208 print("one"); |
174 print("two"); | 209 print("two"); |
175 print("three"); | 210 print("three"); |
176 print("four"); | 211 print("four"); |
177 }); | 212 }); |
178 """, [ | 213 """, [ |
179 _start, | 214 _start, |
180 _testStart(0, "loading test.dart"), | 215 _testStart(0, "loading test.dart", groupIDs: []), |
181 _testDone(0, hidden: true), | 216 _testDone(0, hidden: true), |
182 _testStart(1, 'test'), | 217 _group(1), |
183 _print(1, "one"), | 218 _testStart(2, 'test'), |
184 _print(1, "two"), | 219 _print(2, "one"), |
185 _print(1, "three"), | 220 _print(2, "two"), |
186 _print(1, "four"), | 221 _print(2, "three"), |
187 _testDone(1), | 222 _print(2, "four"), |
| 223 _testDone(2), |
188 _done() | 224 _done() |
189 ]); | 225 ]); |
190 }); | 226 }); |
191 | 227 |
192 test("handles a print after the test completes", () { | 228 test("handles a print after the test completes", () { |
193 _expectReport(""" | 229 _expectReport(""" |
194 // This completer ensures that the test isolate isn't killed until all | 230 // This completer ensures that the test isolate isn't killed until all |
195 // prints have happened. | 231 // prints have happened. |
196 var testDone = new Completer(); | 232 var testDone = new Completer(); |
197 var waitStarted = new Completer(); | 233 var waitStarted = new Completer(); |
198 test('test', () async { | 234 test('test', () async { |
199 waitStarted.future.then((_) { | 235 waitStarted.future.then((_) { |
200 new Future(() => print("one")); | 236 new Future(() => print("one")); |
201 new Future(() => print("two")); | 237 new Future(() => print("two")); |
202 new Future(() => print("three")); | 238 new Future(() => print("three")); |
203 new Future(() => print("four")); | 239 new Future(() => print("four")); |
204 new Future(testDone.complete); | 240 new Future(testDone.complete); |
205 }); | 241 }); |
206 }); | 242 }); |
207 | 243 |
208 test('wait', () { | 244 test('wait', () { |
209 waitStarted.complete(); | 245 waitStarted.complete(); |
210 return testDone.future; | 246 return testDone.future; |
211 }); | 247 }); |
212 """, [ | 248 """, [ |
213 _start, | 249 _start, |
214 _testStart(0, "loading test.dart"), | 250 _testStart(0, "loading test.dart", groupIDs: []), |
215 _testDone(0, hidden: true), | 251 _testDone(0, hidden: true), |
216 _testStart(1, 'test'), | 252 _group(1), |
217 _testDone(1), | 253 _testStart(2, 'test'), |
218 _testStart(2, 'wait'), | |
219 _print(1, "one"), | |
220 _print(1, "two"), | |
221 _print(1, "three"), | |
222 _print(1, "four"), | |
223 _testDone(2), | 254 _testDone(2), |
| 255 _testStart(3, 'wait'), |
| 256 _print(2, "one"), |
| 257 _print(2, "two"), |
| 258 _print(2, "three"), |
| 259 _print(2, "four"), |
| 260 _testDone(3), |
224 _done() | 261 _done() |
225 ]); | 262 ]); |
226 }); | 263 }); |
227 | 264 |
228 test("interleaves prints and errors", () { | 265 test("interleaves prints and errors", () { |
229 _expectReport(""" | 266 _expectReport(""" |
230 // This completer ensures that the test isolate isn't killed until all | 267 // This completer ensures that the test isolate isn't killed until all |
231 // prints have happened. | 268 // prints have happened. |
232 var completer = new Completer(); | 269 var completer = new Completer(); |
233 test('test', () { | 270 test('test', () { |
(...skipping 10 matching lines...) Expand all Loading... |
244 }); | 281 }); |
245 | 282 |
246 print("one"); | 283 print("one"); |
247 print("two"); | 284 print("two"); |
248 throw "first error"; | 285 throw "first error"; |
249 }); | 286 }); |
250 | 287 |
251 test('wait', () => completer.future); | 288 test('wait', () => completer.future); |
252 """, [ | 289 """, [ |
253 _start, | 290 _start, |
254 _testStart(0, "loading test.dart"), | 291 _testStart(0, "loading test.dart", groupIDs: []), |
255 _testDone(0, hidden: true), | 292 _testDone(0, hidden: true), |
256 _testStart(1, 'test'), | 293 _group(1), |
257 _print(1, "one"), | 294 _testStart(2, 'test'), |
258 _print(1, "two"), | 295 _print(2, "one"), |
259 _error(1, "first error"), | 296 _print(2, "two"), |
260 _print(1, "three"), | 297 _error(2, "first error"), |
261 _print(1, "four"), | 298 _print(2, "three"), |
262 _error(1, "second error"), | 299 _print(2, "four"), |
263 _print(1, "five"), | 300 _error(2, "second error"), |
264 _print(1, "six"), | 301 _print(2, "five"), |
265 _testDone(1, result: "error"), | 302 _print(2, "six"), |
266 _testStart(2, 'wait'), | 303 _testDone(2, result: "error"), |
267 _testDone(2), | 304 _testStart(3, 'wait'), |
| 305 _testDone(3), |
268 _done(success: false) | 306 _done(success: false) |
269 ]); | 307 ]); |
270 }); | 308 }); |
271 }); | 309 }); |
272 | 310 |
273 group("skip:", () { | 311 group("skip:", () { |
274 test("reports skipped tests", () { | 312 test("reports skipped tests", () { |
275 _expectReport(""" | 313 _expectReport(""" |
276 test('skip 1', () {}, skip: true); | 314 test('skip 1', () {}, skip: true); |
277 test('skip 2', () {}, skip: true); | 315 test('skip 2', () {}, skip: true); |
278 test('skip 3', () {}, skip: true); | 316 test('skip 3', () {}, skip: true); |
279 """, [ | 317 """, [ |
280 _start, | 318 _start, |
281 _testStart(0, "loading test.dart"), | 319 _testStart(0, "loading test.dart", groupIDs: []), |
282 _testDone(0, hidden: true), | 320 _testDone(0, hidden: true), |
283 _testStart(1, "skip 1", skip: true), | 321 _group(1), |
284 _testDone(1), | 322 _testStart(2, "skip 1", skip: true), |
285 _testStart(2, "skip 2", skip: true), | |
286 _testDone(2), | 323 _testDone(2), |
287 _testStart(3, "skip 3", skip: true), | 324 _testStart(3, "skip 2", skip: true), |
| 325 _testDone(3), |
| 326 _testStart(4, "skip 3", skip: true), |
| 327 _testDone(4), |
| 328 _done() |
| 329 ]); |
| 330 }); |
| 331 |
| 332 test("reports skipped groups", () { |
| 333 _expectReport(""" |
| 334 group('skip', () { |
| 335 test('success 1', () {}); |
| 336 test('success 2', () {}); |
| 337 test('success 3', () {}); |
| 338 }, skip: true); |
| 339 """, [ |
| 340 _start, |
| 341 _testStart(0, "loading test.dart", groupIDs: []), |
| 342 _testDone(0, hidden: true), |
| 343 _group(1), |
| 344 _group(2, name: "skip", parentID: 1, skip: true), |
| 345 _testStart(3, "skip", groupIDs: [1, 2], skip: true), |
288 _testDone(3), | 346 _testDone(3), |
289 _done() | 347 _done() |
290 ]); | 348 ]); |
291 }); | 349 }); |
292 | 350 |
293 test("reports the skip reason if available", () { | 351 test("reports the skip reason if available", () { |
294 _expectReport(""" | 352 _expectReport(""" |
295 test('skip 1', () {}, skip: 'some reason'); | 353 test('skip 1', () {}, skip: 'some reason'); |
296 test('skip 2', () {}, skip: 'or another'); | 354 test('skip 2', () {}, skip: 'or another'); |
297 """, [ | 355 """, [ |
298 _start, | 356 _start, |
299 _testStart(0, "loading test.dart"), | 357 _testStart(0, "loading test.dart", groupIDs: []), |
300 _testDone(0, hidden: true), | 358 _testDone(0, hidden: true), |
301 _testStart(1, "skip 1", skip: "some reason"), | 359 _group(1), |
302 _testDone(1), | 360 _testStart(2, "skip 1", skip: "some reason"), |
303 _testStart(2, "skip 2", skip: "or another"), | |
304 _testDone(2), | 361 _testDone(2), |
| 362 _testStart(3, "skip 2", skip: "or another"), |
| 363 _testDone(3), |
305 _done() | 364 _done() |
306 ]); | 365 ]); |
307 }); | 366 }); |
308 }); | 367 }); |
309 } | 368 } |
310 | 369 |
311 /// Asserts that the tests defined by [tests] produce the JSON events in | 370 /// Asserts that the tests defined by [tests] produce the JSON events in |
312 /// [expected]. | 371 /// [expected]. |
313 void _expectReport(String tests, List<Map> expected) { | 372 void _expectReport(String tests, List<Map> expected) { |
314 var dart = """ | 373 var dart = """ |
(...skipping 23 matching lines...) Expand all Loading... |
338 // Remove excess trailing whitespace. | 397 // Remove excess trailing whitespace. |
339 for (var i = 0; i < stdoutLines.length; i++) { | 398 for (var i = 0; i < stdoutLines.length; i++) { |
340 var event = JSON.decode(stdoutLines[i]); | 399 var event = JSON.decode(stdoutLines[i]); |
341 expect(event.remove("time"), new isInstanceOf<int>()); | 400 expect(event.remove("time"), new isInstanceOf<int>()); |
342 event.remove("stackTrace"); | 401 event.remove("stackTrace"); |
343 expect(event, equals(expected[i])); | 402 expect(event, equals(expected[i])); |
344 } | 403 } |
345 }); | 404 }); |
346 } | 405 } |
347 | 406 |
| 407 /// Returns the event emitted by the JSON reporter indicating that a group has |
| 408 /// begun running. |
| 409 /// |
| 410 /// If [skip] is `true`, the group is expected to be marked as skipped without a |
| 411 /// reason. If it's a [String], the group is expected to be marked as skipped |
| 412 /// with that reason. |
| 413 Map _group(int id, {String name, int parentID, skip}) { |
| 414 return { |
| 415 "type": "group", |
| 416 "group": { |
| 417 "id": id, |
| 418 "name": name, |
| 419 "parentID": parentID, |
| 420 "metadata": _metadata(skip: skip) |
| 421 } |
| 422 }; |
| 423 } |
| 424 |
348 /// Returns the event emitted by the JSON reporter indicating that a test has | 425 /// Returns the event emitted by the JSON reporter indicating that a test has |
349 /// begun running. | 426 /// begun running. |
350 /// | 427 /// |
351 /// If [skip] is `true`, the test is expected to be marked as skipped without a | 428 /// If [parentIDs] is passed, it's the IDs of groups containing this test. If |
| 429 /// [skip] is `true`, the test is expected to be marked as skipped without a |
352 /// reason. If it's a [String], the test is expected to be marked as skipped | 430 /// reason. If it's a [String], the test is expected to be marked as skipped |
353 /// with that reason. | 431 /// with that reason. |
354 Map _testStart(int id, String name, {skip}) { | 432 Map _testStart(int id, String name, {Iterable<int> groupIDs, skip}) { |
355 var metadata; | |
356 if (skip == true) { | |
357 metadata = {"skip": true, "skipReason": null}; | |
358 } else if (skip is String) { | |
359 metadata = {"skip": true, "skipReason": skip}; | |
360 } else { | |
361 metadata = {"skip": false, "skipReason": null}; | |
362 } | |
363 | |
364 return { | 433 return { |
365 "type": "testStart", | 434 "type": "testStart", |
366 "test": {"id": id, "name": name, "metadata": metadata} | 435 "test": { |
| 436 "id": id, |
| 437 "name": name, |
| 438 "groupIDs": groupIDs ?? [1], |
| 439 "metadata": _metadata(skip: skip) |
| 440 } |
367 }; | 441 }; |
368 } | 442 } |
369 | 443 |
370 /// Returns the event emitted by the JSON reporter indicating that a test | 444 /// Returns the event emitted by the JSON reporter indicating that a test |
371 /// printed [message]. | 445 /// printed [message]. |
372 Map _print(int id, String message) { | 446 Map _print(int id, String message) { |
373 return { | 447 return { |
374 "type": "print", | 448 "type": "print", |
375 "testID": id, | 449 "testID": id, |
376 "message": message | 450 "message": message |
(...skipping 20 matching lines...) Expand all Loading... |
397 /// The [result] parameter indicates the result of the test. It defaults to | 471 /// The [result] parameter indicates the result of the test. It defaults to |
398 /// `"success"`. | 472 /// `"success"`. |
399 /// | 473 /// |
400 /// The [hidden] parameter indicates whether the test should not be displayed | 474 /// The [hidden] parameter indicates whether the test should not be displayed |
401 /// after finishing. | 475 /// after finishing. |
402 Map _testDone(int id, {String result, bool hidden: false}) { | 476 Map _testDone(int id, {String result, bool hidden: false}) { |
403 result ??= "success"; | 477 result ??= "success"; |
404 return {"type": "testDone", "testID": id, "result": result, "hidden": hidden}; | 478 return {"type": "testDone", "testID": id, "result": result, "hidden": hidden}; |
405 } | 479 } |
406 | 480 |
| 481 /// Returns the event emitted by the JSON reporter indicating that the entire |
| 482 /// run finished. |
407 Map _done({bool success: true}) => {"type": "done", "success": success}; | 483 Map _done({bool success: true}) => {"type": "done", "success": success}; |
| 484 |
| 485 /// Returns the serialized metadata corresponding to [skip]. |
| 486 Map _metadata({skip}) { |
| 487 if (skip == true) { |
| 488 return {"skip": true, "skipReason": null}; |
| 489 } else if (skip is String) { |
| 490 return {"skip": true, "skipReason": skip}; |
| 491 } else { |
| 492 return {"skip": false, "skipReason": null}; |
| 493 } |
| 494 } |
OLD | NEW |