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

Side by Side Diff: test/utils.dart

Issue 1036943002: Add a testOn parameter to test() and group(). (Closed) Base URL: git@github.com:dart-lang/unittest@master
Patch Set: Created 5 years, 9 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/test_on_test.dart ('k') | no next file » | 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 library unittest.test.utils; 5 library unittest.test.utils;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:unittest/src/backend/invoker.dart'; 10 import 'package:unittest/src/backend/invoker.dart';
11 import 'package:unittest/src/backend/live_test.dart'; 11 import 'package:unittest/src/backend/live_test.dart';
12 import 'package:unittest/src/backend/metadata.dart';
12 import 'package:unittest/src/backend/state.dart'; 13 import 'package:unittest/src/backend/state.dart';
13 import 'package:unittest/src/backend/suite.dart'; 14 import 'package:unittest/src/backend/suite.dart';
14 import 'package:unittest/src/runner/load_exception.dart'; 15 import 'package:unittest/src/runner/load_exception.dart';
15 import 'package:unittest/src/util/remote_exception.dart'; 16 import 'package:unittest/src/util/remote_exception.dart';
16 import 'package:unittest/unittest.dart'; 17 import 'package:unittest/unittest.dart';
17 18
18 // The last state change detected via [expectStates]. 19 // The last state change detected via [expectStates].
19 State lastState; 20 State lastState;
20 21
21 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange]. 22 /// Asserts that exactly [states] will be emitted via [liveTest.onStateChange].
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 if (times == 0) return new Future.value(); 172 if (times == 0) return new Future.value();
172 // Use [new Future] future to allow microtask events to finish. The [new 173 // Use [new Future] future to allow microtask events to finish. The [new
173 // Future.value] constructor uses scheduleMicrotask itself and would therefore 174 // Future.value] constructor uses scheduleMicrotask itself and would therefore
174 // not wait for microtask callbacks that are scheduled after invoking this 175 // not wait for microtask callbacks that are scheduled after invoking this
175 // method. 176 // method.
176 return new Future(() => pumpEventQueue(times - 1)); 177 return new Future(() => pumpEventQueue(times - 1));
177 } 178 }
178 179
179 /// Returns a local [LiveTest] that runs [body]. 180 /// Returns a local [LiveTest] that runs [body].
180 LiveTest createTest(body()) { 181 LiveTest createTest(body()) {
181 var test = new LocalTest("test", body); 182 var test = new LocalTest("test", new Metadata(), body);
182 var suite = new Suite([test]); 183 var suite = new Suite([test]);
183 return test.load(suite); 184 return test.load(suite);
184 } 185 }
185 186
186 /// Runs [body] as a test. 187 /// Runs [body] as a test.
187 /// 188 ///
188 /// Once it completes, returns the [LiveTest] used to run it. 189 /// Once it completes, returns the [LiveTest] used to run it.
189 Future<LiveTest> runTest(body()) { 190 Future<LiveTest> runTest(body()) {
190 var liveTest = createTest(body); 191 var liveTest = createTest(body);
191 return liveTest.run().then((_) => liveTest); 192 return liveTest.run().then((_) => liveTest);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 }); 233 });
233 }); 234 });
234 235
235 return liveTest.run().then((_) { 236 return liveTest.run().then((_) {
236 expectTestPassed(liveTest); 237 expectTestPassed(liveTest);
237 // Ensure that the outer test doesn't complete until the inner future 238 // Ensure that the outer test doesn't complete until the inner future
238 // completes. 239 // completes.
239 return future; 240 return future;
240 }); 241 });
241 } 242 }
OLDNEW
« no previous file with comments | « test/runner/test_on_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698