OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 import 'package:scheduled_test/scheduled_test.dart'; | 5 import 'package:scheduled_test/scheduled_test.dart'; |
6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; | 6 import 'package:scheduled_test/src/mock_clock.dart' as mock_clock; |
7 | 7 |
8 import '../metatest.dart'; | 8 import 'package:metatest/metatest.dart'; |
9 import '../utils.dart'; | 9 import '../utils.dart'; |
10 | 10 |
11 void main(_, message) { | 11 void main() => initTests(_test); |
| 12 |
| 13 void _test(message) { |
12 initMetatest(message); | 14 initMetatest(message); |
13 | 15 |
14 setUpTimeout(); | 16 setUpTimeout(); |
15 | 17 |
16 expectTests('a scheduled test with an out-of-band error should fail', () { | 18 expectTestResults('a scheduled test with an out-of-band error should fail', |
| 19 () { |
17 mock_clock.mock().run(); | 20 mock_clock.mock().run(); |
18 test('test 1', () { | 21 test('test 1', () { |
19 sleep(1).then((_) => throw 'error'); | 22 sleep(1).then((_) => throw 'error'); |
20 }); | 23 }); |
21 | 24 |
22 test('test 2', () { | 25 test('test 2', () { |
23 return sleep(2); | 26 return sleep(2); |
24 }); | 27 }); |
25 }, {'test 1': ERROR, 'test 2': PASS}); | 28 }, [{ |
| 29 'description': 'test 1', |
| 30 'result': 'error' |
| 31 }, { |
| 32 'description': 'test 2', |
| 33 'result': 'pass' |
| 34 }]); |
26 | 35 |
27 expectTestsPass('currentSchedule.errors contains the error in the onComplete ' | 36 expectTestsPass('currentSchedule.errors contains the error in the onComplete ' |
28 'queue', () { | 37 'queue', () { |
29 var errors; | 38 var errors; |
30 test('test 1', () { | 39 test('test 1', () { |
31 currentSchedule.onComplete.schedule(() { | 40 currentSchedule.onComplete.schedule(() { |
32 errors = currentSchedule.errors; | 41 errors = currentSchedule.errors; |
33 }); | 42 }); |
34 | 43 |
35 throw 'error'; | 44 throw 'error'; |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 throw 'in-band'; | 249 throw 'in-band'; |
241 })); | 250 })); |
242 }); | 251 }); |
243 | 252 |
244 test('test 2', () { | 253 test('test 2', () { |
245 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); | 254 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); |
246 expect(errors.map((e) => e.error), equals(['in-band', 'out-of-band'])); | 255 expect(errors.map((e) => e.error), equals(['in-band', 'out-of-band'])); |
247 }); | 256 }); |
248 }, passing: ['test 2']); | 257 }, passing: ['test 2']); |
249 } | 258 } |
OLD | NEW |