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

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: status fixes 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
« no previous file with comments | « pkg/unittest/test/missing_tick_test.dart ('k') | pkg/unittest/test/protect_async_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 expectTestsPass('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 });
40 test('after nest', () {
41 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D ");
42 });
37 }); 43 });
38 test('after nest', () { 44 }
39 expect(s.toString(), "l1 U l2 U l4 U l5 U l6 D l4 D l2 D "); 45
46
47 Function makeDelayedSetup(int index, StringBuffer s) => () {
48 return new Future.delayed(new Duration(milliseconds: 1), () {
49 s.write('l$index U ');
40 }); 50 });
41 }; 51 };
42 52
43 var expected = buildStatusString(2, 0, 0, 53 Function makeDelayedTeardown(int index, StringBuffer s) => () {
44 'level 1 level 2 level 3 level 4 level 5 level 6 inner::' 54 return new Future.delayed(new Duration(milliseconds: 1), () {
45 'after nest'); 55 s.write('l$index D ');
56 });
57 };
58
59 Function makeImmediateSetup(int index, StringBuffer s) => () {
60 s.write('l$index U ');
61 };
62
63 Function makeImmediateTeardown(int index, StringBuffer s) => () {
64 s.write('l$index D ');
65 };
OLDNEW
« no previous file with comments | « pkg/unittest/test/missing_tick_test.dart ('k') | pkg/unittest/test/protect_async_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698