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

Side by Side Diff: test/runner/load_suite_test.dart

Issue 1390883002: Make Suite contain a single Group. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 2 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
« no previous file with comments | « test/runner/isolate_listener_test.dart ('k') | test/runner/loader_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) 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:async'; 7 import 'dart:async';
8 8
9 import 'package:test/src/backend/group.dart';
9 import 'package:test/src/backend/state.dart'; 10 import 'package:test/src/backend/state.dart';
10 import 'package:test/src/backend/test_platform.dart'; 11 import 'package:test/src/backend/test_platform.dart';
11 import 'package:test/src/runner/load_exception.dart'; 12 import 'package:test/src/runner/load_exception.dart';
12 import 'package:test/src/runner/load_suite.dart'; 13 import 'package:test/src/runner/load_suite.dart';
13 import 'package:test/src/runner/runner_suite.dart'; 14 import 'package:test/src/runner/runner_suite.dart';
14 import 'package:test/src/runner/vm/environment.dart'; 15 import 'package:test/src/runner/vm/environment.dart';
15 import 'package:test/test.dart'; 16 import 'package:test/test.dart';
16 17
17 import '../utils.dart'; 18 import '../utils.dart';
18 19
19 void main() { 20 void main() {
20 var innerSuite; 21 var innerSuite;
21 setUp(() => innerSuite = new RunnerSuite(const VMEnvironment(), [])); 22 setUp(() {
23 innerSuite = new RunnerSuite(const VMEnvironment(), new Group.root([]));
24 });
22 25
23 test("running a load test causes LoadSuite.suite to emit a suite", () async { 26 test("running a load test causes LoadSuite.suite to emit a suite", () async {
24 var suite = new LoadSuite("name", () => new Future.value(innerSuite)); 27 var suite = new LoadSuite("name", () => new Future.value(innerSuite));
25 expect(suite.entries, hasLength(1)); 28 expect(suite.group.entries, hasLength(1));
26 29
27 expect(suite.suite, completion(equals(innerSuite))); 30 expect(suite.suite, completion(equals(innerSuite)));
28 var liveTest = await suite.entries.single.load(suite); 31 var liveTest = await suite.group.entries.single.load(suite);
29 await liveTest.run(); 32 await liveTest.run();
30 expectTestPassed(liveTest); 33 expectTestPassed(liveTest);
31 }); 34 });
32 35
33 test("running a load suite's body may be synchronous", () async { 36 test("running a load suite's body may be synchronous", () async {
34 var suite = new LoadSuite("name", () => innerSuite); 37 var suite = new LoadSuite("name", () => innerSuite);
35 expect(suite.entries, hasLength(1)); 38 expect(suite.group.entries, hasLength(1));
36 39
37 expect(suite.suite, completion(equals(innerSuite))); 40 expect(suite.suite, completion(equals(innerSuite)));
38 var liveTest = await suite.entries.single.load(suite); 41 var liveTest = await suite.group.entries.single.load(suite);
39 await liveTest.run(); 42 await liveTest.run();
40 expectTestPassed(liveTest); 43 expectTestPassed(liveTest);
41 }); 44 });
42 45
43 test("a load test doesn't complete until the body returns", () async { 46 test("a load test doesn't complete until the body returns", () async {
44 var completer = new Completer(); 47 var completer = new Completer();
45 var suite = new LoadSuite("name", () => completer.future); 48 var suite = new LoadSuite("name", () => completer.future);
46 expect(suite.entries, hasLength(1)); 49 expect(suite.group.entries, hasLength(1));
47 50
48 var liveTest = await suite.entries.single.load(suite); 51 var liveTest = await suite.group.entries.single.load(suite);
49 expect(liveTest.run(), completes); 52 expect(liveTest.run(), completes);
50 await new Future.delayed(Duration.ZERO); 53 await new Future.delayed(Duration.ZERO);
51 expect(liveTest.state.status, equals(Status.running)); 54 expect(liveTest.state.status, equals(Status.running));
52 55
53 completer.complete(innerSuite); 56 completer.complete(innerSuite);
54 await new Future.delayed(Duration.ZERO); 57 await new Future.delayed(Duration.ZERO);
55 expectTestPassed(liveTest); 58 expectTestPassed(liveTest);
56 }); 59 });
57 60
58 test("a load test forwards errors and completes LoadSuite.suite to null", 61 test("a load test forwards errors and completes LoadSuite.suite to null",
59 () async { 62 () async {
60 var suite = new LoadSuite("name", () => fail("error")); 63 var suite = new LoadSuite("name", () => fail("error"));
61 expect(suite.entries, hasLength(1)); 64 expect(suite.group.entries, hasLength(1));
62 65
63 expect(suite.suite, completion(isNull)); 66 expect(suite.suite, completion(isNull));
64 67
65 var liveTest = await suite.entries.single.load(suite); 68 var liveTest = await suite.group.entries.single.load(suite);
66 await liveTest.run(); 69 await liveTest.run();
67 expectTestFailed(liveTest, "error"); 70 expectTestFailed(liveTest, "error");
68 }); 71 });
69 72
70 test("a load test completes early if it's closed", () async { 73 test("a load test completes early if it's closed", () async {
71 var suite = new LoadSuite("name", () => new Completer().future); 74 var suite = new LoadSuite("name", () => new Completer().future);
72 expect(suite.entries, hasLength(1)); 75 expect(suite.group.entries, hasLength(1));
73 76
74 var liveTest = await suite.entries.single.load(suite); 77 var liveTest = await suite.group.entries.single.load(suite);
75 expect(liveTest.run(), completes); 78 expect(liveTest.run(), completes);
76 await new Future.delayed(Duration.ZERO); 79 await new Future.delayed(Duration.ZERO);
77 expect(liveTest.state.status, equals(Status.running)); 80 expect(liveTest.state.status, equals(Status.running));
78 81
79 expect(liveTest.close(), completes); 82 expect(liveTest.close(), completes);
80 }); 83 });
81 84
82 test("forLoadException() creates a suite that completes to a LoadException", 85 test("forLoadException() creates a suite that completes to a LoadException",
83 () async { 86 () async {
84 var exception = new LoadException("path", "error"); 87 var exception = new LoadException("path", "error");
85 var suite = new LoadSuite.forLoadException(exception); 88 var suite = new LoadSuite.forLoadException(exception);
86 expect(suite.entries, hasLength(1)); 89 expect(suite.group.entries, hasLength(1));
87 90
88 expect(suite.suite, completion(isNull)); 91 expect(suite.suite, completion(isNull));
89 92
90 var liveTest = await suite.entries.single.load(suite); 93 var liveTest = await suite.group.entries.single.load(suite);
91 await liveTest.run(); 94 await liveTest.run();
92 expect(liveTest.state.status, equals(Status.complete)); 95 expect(liveTest.state.status, equals(Status.complete));
93 expect(liveTest.state.result, equals(Result.error)); 96 expect(liveTest.state.result, equals(Result.error));
94 expect(liveTest.errors, hasLength(1)); 97 expect(liveTest.errors, hasLength(1));
95 expect(liveTest.errors.first.error, equals(exception)); 98 expect(liveTest.errors.first.error, equals(exception));
96 }); 99 });
97 100
98 test("forSuite() creates a load suite that completes to a test suite", 101 test("forSuite() creates a load suite that completes to a test suite",
99 () async { 102 () async {
100 var suite = new LoadSuite.forSuite(innerSuite); 103 var suite = new LoadSuite.forSuite(innerSuite);
101 expect(suite.entries, hasLength(1)); 104 expect(suite.group.entries, hasLength(1));
102 105
103 expect(suite.suite, completion(equals(innerSuite))); 106 expect(suite.suite, completion(equals(innerSuite)));
104 var liveTest = await suite.entries.single.load(suite); 107 var liveTest = await suite.group.entries.single.load(suite);
105 await liveTest.run(); 108 await liveTest.run();
106 expectTestPassed(liveTest); 109 expectTestPassed(liveTest);
107 }); 110 });
108 111
109 group("changeSuite()", () { 112 group("changeSuite()", () {
110 test("returns a new load suite with the same properties", () { 113 test("returns a new load suite with the same properties", () {
111 var suite = new LoadSuite("name", () => innerSuite, 114 var suite = new LoadSuite("name", () => innerSuite,
112 platform: TestPlatform.vm); 115 platform: TestPlatform.vm);
113 expect(suite.entries, hasLength(1)); 116 expect(suite.group.entries, hasLength(1));
114 117
115 var newSuite = suite.changeSuite((suite) => suite); 118 var newSuite = suite.changeSuite((suite) => suite);
116 expect(newSuite.platform, equals(TestPlatform.vm)); 119 expect(newSuite.platform, equals(TestPlatform.vm));
117 expect(newSuite.entries.single.name, equals(suite.entries.single.name)); 120 expect(newSuite.group.entries.single.name, equals(suite.group.entries.sing le.name));
118 }); 121 });
119 122
120 test("changes the inner suite", () async { 123 test("changes the inner suite", () async {
121 var suite = new LoadSuite("name", () => innerSuite); 124 var suite = new LoadSuite("name", () => innerSuite);
122 expect(suite.entries, hasLength(1)); 125 expect(suite.group.entries, hasLength(1));
123 126
124 var newInnerSuite = new RunnerSuite(const VMEnvironment(), []); 127 var newInnerSuite = new RunnerSuite(
128 const VMEnvironment(), new Group.root([]));
125 var newSuite = suite.changeSuite((suite) => newInnerSuite); 129 var newSuite = suite.changeSuite((suite) => newInnerSuite);
126 expect(newSuite.suite, completion(equals(newInnerSuite))); 130 expect(newSuite.suite, completion(equals(newInnerSuite)));
127 131
128 var liveTest = await suite.entries.single.load(suite); 132 var liveTest = await suite.group.entries.single.load(suite);
129 await liveTest.run(); 133 await liveTest.run();
130 expectTestPassed(liveTest); 134 expectTestPassed(liveTest);
131 }); 135 });
132 136
133 test("doesn't run change() if the suite is null", () async { 137 test("doesn't run change() if the suite is null", () async {
134 var suite = new LoadSuite("name", () => null); 138 var suite = new LoadSuite("name", () => null);
135 expect(suite.entries, hasLength(1)); 139 expect(suite.group.entries, hasLength(1));
136 140
137 var newSuite = suite.changeSuite(expectAsync((_) {}, count: 0)); 141 var newSuite = suite.changeSuite(expectAsync((_) {}, count: 0));
138 expect(newSuite.suite, completion(isNull)); 142 expect(newSuite.suite, completion(isNull));
139 143
140 var liveTest = await suite.entries.single.load(suite); 144 var liveTest = await suite.group.entries.single.load(suite);
141 await liveTest.run(); 145 await liveTest.run();
142 expectTestPassed(liveTest); 146 expectTestPassed(liveTest);
143 }); 147 });
144 }); 148 });
145 149
146 group("getSuite()", () { 150 group("getSuite()", () {
147 test("runs the test and returns the suite", () { 151 test("runs the test and returns the suite", () {
148 var suite = new LoadSuite.forSuite(innerSuite); 152 var suite = new LoadSuite.forSuite(innerSuite);
149 expect(suite.entries, hasLength(1)); 153 expect(suite.group.entries, hasLength(1));
150 154
151 expect(suite.getSuite(), completion(equals(innerSuite))); 155 expect(suite.getSuite(), completion(equals(innerSuite)));
152 }); 156 });
153 157
154 test("forwards errors to the future", () { 158 test("forwards errors to the future", () {
155 var suite = new LoadSuite("name", () => throw "error"); 159 var suite = new LoadSuite("name", () => throw "error");
156 expect(suite.entries, hasLength(1)); 160 expect(suite.group.entries, hasLength(1));
157 161
158 expect(suite.getSuite(), throwsA("error")); 162 expect(suite.getSuite(), throwsA("error"));
159 }); 163 });
160 }); 164 });
161 } 165 }
OLDNEW
« no previous file with comments | « test/runner/isolate_listener_test.dart ('k') | test/runner/loader_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698