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

Side by Side Diff: pkg/unittest/test/nested_groups_setup_teardown_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 library unittestTest; 5 library unittest.nested_groups_setup_teardown_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:isolate';
9 8
10 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
11 10
12 part 'utils.dart'; 11 import 'package:metatest/metatest.dart';
13 12
14 var testName = 'nested groups setup/teardown'; 13 void main() => initTests(_test);
15 14
16 var testFunction = (_) { 15 void _test(message) {
17 StringBuffer s = new StringBuffer(); 16 initMetatest(message);
18 group('level 1', () { 17
19 setUp(makeDelayedSetup(1, s)); 18 expectTestResults('nested groups setup/teardown', () {
20 group('level 2', () { 19 StringBuffer s = new StringBuffer();
21 setUp(makeImmediateSetup(2, s)); 20 group('level 1', () {
22 tearDown(makeDelayedTeardown(2, s)); 21 setUp(makeDelayedSetup(1, s));
23 group('level 3', () { 22 group('level 2', () {
24 group('level 4', () { 23 setUp(makeImmediateSetup(2, s));
25 setUp(makeDelayedSetup(4, s)); 24 tearDown(makeDelayedTeardown(2, s));
26 tearDown(makeImmediateTeardown(4, s)); 25 group('level 3', () {
27 group('level 5', () { 26 group('level 4', () {
28 setUp(makeImmediateSetup(5, s)); 27 setUp(makeDelayedSetup(4, s));
29 group('level 6', () { 28 tearDown(makeImmediateTeardown(4, s));
30 tearDown(makeDelayedTeardown(6, s)); 29 group('level 5', () {
31 test('inner', () {}); 30 setUp(makeImmediateSetup(5, s));
31 group('level 6', () {
32 tearDown(makeDelayedTeardown(6, s));
33 test('inner', () {});
34 });
32 }); 35 });
33 }); 36 });
34 }); 37 });
35 }); 38 });
36 }); 39 });
37 }); 40 test('after nest', () {
38 test('after nest', () { 41 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D ");
39 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D "); 42 });
43 }, [{
44 'description': 'level 1 level 2 level 3 level 4 level 5 level 6 inner',
45 'result': 'pass',
46 }, {
47 'description': 'after nest',
48 'result': 'pass',
49 }]);
50 }
51
52
53 Function makeDelayedSetup(int index, StringBuffer s) => () {
54 return new Future.delayed(new Duration(milliseconds: 1), () {
55 s.write('l$index U ');
40 }); 56 });
41 }; 57 };
42 58
43 var expected = buildStatusString(2, 0, 0, 59 Function makeDelayedTeardown(int index, StringBuffer s) => () {
44 'level 1 level 2 level 3 level 4 level 5 level 6 inner::' 60 return new Future.delayed(new Duration(milliseconds: 1), () {
45 'after nest'); 61 s.write('l$index D ');
62 });
63 };
64
65 Function makeImmediateSetup(int index, StringBuffer s) => () {
66 s.write('l$index U ');
67 };
68
69 Function makeImmediateTeardown(int index, StringBuffer s) => () {
70 s.write('l$index D ');
71 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698