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

Side by Side Diff: pkg/unittest/test/with_test_environment_test.dart

Issue 740323002: Incorporating nweiz' feedback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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 | « no previous file | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.with_test_environment_test; 5 library unittest.with_test_environment_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 class TestConfiguration extends SimpleConfiguration { 10 class TestConfiguration extends SimpleConfiguration {
11 final Completer _completer = new Completer(); 11 final Completer _completer = new Completer();
12 List<TestCase> _results; 12 List<TestCase> _results;
13 13
14 TestConfiguration(); 14 TestConfiguration();
15 15
16 void onSummary(int passed, int failed, int errors, List<TestCase> results, 16 void onSummary(int passed, int failed, int errors, List<TestCase> results,
17 String uncaughtError) { 17 String uncaughtError) {
18 super.onSummary(passed, failed, errors, results, uncaughtError); 18 super.onSummary(passed, failed, errors, results, uncaughtError);
19 _results = results; 19 _results = results;
20 } 20 }
21 21
22 Future get done => _completer.future; 22 Future get done => _completer.future;
23 23
24 onDone(success) { 24 onDone(success) {
25 new Future.sync(() { 25 new Future.sync(() => super.onDone(success))
26 super.onDone(success); 26 .then(_completer.complete)
27 }).then((_) => _completer.complete(_)) 27 .catchError(_completer.completeError);
28 .catchError((error, stack) => _completer.completeError(error, stack));
29 } 28 }
30 29
31 bool checkIfTestRan(String testName) { 30 bool checkIfTestRan(String testName) {
32 for (final t in _results) { 31 return _results.any((test) => test.description == testName);
33 if (t.description == testName) {
34 return true;
35 }
36 }
37 return false;
38 } 32 }
39 } 33 }
40 34
41 Future runUnittests(Function callback) { 35 Future runUnittests(Function callback) {
42 var config = new TestConfiguration(); 36 var config = new TestConfiguration();
43 unittestConfiguration = config; 37 unittestConfiguration = config;
44 callback(); 38 callback();
45 39
46 return config.done; 40 return config.done;
47 } 41 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 }); 81 });
88 82
89 // Third test that we can run with two nested test environments. 83 // Third test that we can run with two nested test environments.
90 withTestEnvironment(() { 84 withTestEnvironment(() {
91 runUnittests(runTests); 85 runUnittests(runTests);
92 withTestEnvironment(() { 86 withTestEnvironment(() {
93 runUnittests(runTests1); 87 runUnittests(runTests1);
94 }); 88 });
95 }); 89 });
96 } 90 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698