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

Side by Side Diff: test/utils.dart

Issue 1400743002: Add support for setUpAll and tearDownAll. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: 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/tear_down_all_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 test.test.utils; 5 library test.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:test/src/backend/declarer.dart'; 10 import 'package:test/src/backend/declarer.dart';
11 import 'package:test/src/backend/group.dart'; 11 import 'package:test/src/backend/group.dart';
12 import 'package:test/src/backend/group_entry.dart'; 12 import 'package:test/src/backend/group_entry.dart';
13 import 'package:test/src/backend/invoker.dart'; 13 import 'package:test/src/backend/invoker.dart';
14 import 'package:test/src/backend/live_test.dart'; 14 import 'package:test/src/backend/live_test.dart';
15 import 'package:test/src/backend/metadata.dart'; 15 import 'package:test/src/backend/metadata.dart';
16 import 'package:test/src/backend/state.dart'; 16 import 'package:test/src/backend/state.dart';
17 import 'package:test/src/backend/suite.dart'; 17 import 'package:test/src/backend/suite.dart';
18 import 'package:test/src/runner/application_exception.dart'; 18 import 'package:test/src/runner/application_exception.dart';
19 import 'package:test/src/runner/engine.dart';
19 import 'package:test/src/runner/load_exception.dart'; 20 import 'package:test/src/runner/load_exception.dart';
21 import 'package:test/src/runner/runner_suite.dart';
22 import 'package:test/src/runner/vm/environment.dart';
20 import 'package:test/src/util/remote_exception.dart'; 23 import 'package:test/src/util/remote_exception.dart';
21 import 'package:test/test.dart'; 24 import 'package:test/test.dart';
22 25
23 /// The string representation of an untyped closure with no arguments. 26 /// The string representation of an untyped closure with no arguments.
24 /// 27 ///
25 /// This differs between dart2js and the VM. 28 /// This differs between dart2js and the VM.
26 final String closureString = (() {}).toString(); 29 final String closureString = (() {}).toString();
27 30
28 // The last state change detected via [expectStates]. 31 // The last state change detected via [expectStates].
29 State lastState; 32 State lastState;
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 }); 280 });
278 }); 281 });
279 282
280 await liveTest.run(); 283 await liveTest.run();
281 expectTestPassed(liveTest); 284 expectTestPassed(liveTest);
282 // Ensure that the outer test doesn't complete until the inner future 285 // Ensure that the outer test doesn't complete until the inner future
283 // completes. 286 // completes.
284 return future; 287 return future;
285 } 288 }
286 289
290 /// Runs [body] with a declarer, runs all the declared tests, and asserts that
291 /// they pass.
292 Future expectTestsPass(void body()) async {
293 var engine = declareEngine(body);
294 var success = await engine.run();
295
296 for (var test in engine.liveTests) {
297 expectTestPassed(test);
298 }
299
300 expect(success, isTrue);
301 }
302
287 /// Runs [body] with a declarer and returns the declared entries. 303 /// Runs [body] with a declarer and returns the declared entries.
288 List<GroupEntry> declare(void body()) { 304 List<GroupEntry> declare(void body()) {
289 var declarer = new Declarer()..declare(body); 305 var declarer = new Declarer()..declare(body);
290 return declarer.build().entries; 306 return declarer.build().entries;
291 } 307 }
308
309 /// Runs [body] with a declarer and returns an engine that runs those tests.
310 Engine declareEngine(void body()) {
311 var declarer = new Declarer()..declare(body);
312 return new Engine.withSuites([
313 new RunnerSuite(const VMEnvironment(), declarer.build())
314 ]);
315 }
OLDNEW
« no previous file with comments | « test/runner/tear_down_all_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698