Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: pkg/scheduled_test/test/scheduled_test/current_schedule_errors_test.dart

Issue 524153002: Sharing metatest logic between unittest and scheduled_test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: CR feedback Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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', () {
nweiz 2014/09/10 21:04:42 Long line.
kevmoo 2014/09/17 21:16:29 Done.
17 mock_clock.mock().run(); 19 mock_clock.mock().run();
18 test('test 1', () { 20 test('test 1', () {
19 sleep(1).then((_) => throw 'error'); 21 sleep(1).then((_) => throw 'error');
20 }); 22 });
21 23
22 test('test 2', () { 24 test('test 2', () {
23 return sleep(2); 25 return sleep(2);
24 }); 26 });
25 }, {'test 1': ERROR, 'test 2': PASS}); 27 }, [{
28 'description': 'test 1',
29 'result': 'error'
30 }, {
31 'description': 'test 2',
32 'result': 'pass'
33 }]);
26 34
27 expectTestsPass('currentSchedule.errors contains the error in the onComplete ' 35 expectTestsPass('currentSchedule.errors contains the error in the onComplete '
28 'queue', () { 36 'queue', () {
29 var errors; 37 var errors;
30 test('test 1', () { 38 test('test 1', () {
31 currentSchedule.onComplete.schedule(() { 39 currentSchedule.onComplete.schedule(() {
32 errors = currentSchedule.errors; 40 errors = currentSchedule.errors;
33 }); 41 });
34 42
35 throw 'error'; 43 throw 'error';
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 throw 'in-band'; 248 throw 'in-band';
241 })); 249 }));
242 }); 250 });
243 251
244 test('test 2', () { 252 test('test 2', () {
245 expect(errors, everyElement(new isInstanceOf<ScheduleError>())); 253 expect(errors, everyElement(new isInstanceOf<ScheduleError>()));
246 expect(errors.map((e) => e.error), equals(['in-band', 'out-of-band'])); 254 expect(errors.map((e) => e.error), equals(['in-band', 'out-of-band']));
247 }); 255 });
248 }, passing: ['test 2']); 256 }, passing: ['test 2']);
249 } 257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698