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

Side by Side Diff: pkg/unittest/lib/unittest.dart

Issue 12770017: pkg/unittest: config refactor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fixed scheduled_test test Created 7 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 | Annotate | Revision Log
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 /** 5 /**
6 * A library for writing dart unit tests. 6 * A library for writing dart unit tests.
7 * 7 *
8 * To import this library, install the 8 * To import this library, install the
9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub 9 * [unittest package](http://pub.dartlang.org/packages/unittest) via the pub
10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc) 10 * package manager. See the [Getting Started](http://pub.dartlang.org/doc)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 import 'matcher.dart'; 158 import 'matcher.dart';
159 export 'matcher.dart'; 159 export 'matcher.dart';
160 160
161 // TODO(amouravski): We should not need to import mock here, but it's necessary 161 // TODO(amouravski): We should not need to import mock here, but it's necessary
162 // to enable dartdoc on the mock library, as it's not picked up normally. 162 // to enable dartdoc on the mock library, as it's not picked up normally.
163 import 'mock.dart'; 163 import 'mock.dart';
164 164
165 part 'src/config.dart'; 165 part 'src/config.dart';
166 part 'src/test_case.dart'; 166 part 'src/test_case.dart';
167 167
168 Configuration _config;
169
168 /** [Configuration] used by the unittest library. */ 170 /** [Configuration] used by the unittest library. */
169 Configuration _config = null; 171 Configuration get unittestConfiguration => _config;
Siggi Cherem (dart-lang) 2013/03/27 21:05:58 I wouldn't be too scared about external name colli
170
171 Configuration get config => _config;
172 172
173 /** 173 /**
174 * Set the [Configuration] used by the unittest library. Returns any 174 * Sets the [Configuration] used by the unittest library.
175 * previous configuration. 175 *
176 * TODO: consider deprecating in favor of a setter now we have a getter. 176 * Throws a [StateError] if there is an existing, incompatible value.
177 */ 177 */
178 Configuration configure(Configuration config) { 178 void set unittestConfiguration(Configuration value) {
179 Configuration _oldConfig = _config; 179 if(!identical(_config, value)) {
180 _config = config; 180 if(_config != null) {
181 return _oldConfig; 181 throw new StateError('unittestConfiguration has already been set');
182 }
183 _config = value;
184 }
182 } 185 }
183 186
184 void logMessage(String message) => _config.logMessage(message); 187 void logMessage(String message) => _config.logMessage(message);
185 188
186 /** 189 /**
187 * Description text of the current test group. If multiple groups are nested, 190 * Description text of the current test group. If multiple groups are nested,
188 * this will contain all of their text concatenated. 191 * this will contain all of their text concatenated.
189 */ 192 */
190 String _currentGroup = ''; 193 String _currentGroup = '';
191 194
(...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after
800 return; 803 return;
801 } 804 }
802 _initialized = true; 805 _initialized = true;
803 // Hook our async guard into the matcher library. 806 // Hook our async guard into the matcher library.
804 wrapAsync = (f, [id]) => expectAsync1(f, id: id); 807 wrapAsync = (f, [id]) => expectAsync1(f, id: id);
805 808
806 _tests = <TestCase>[]; 809 _tests = <TestCase>[];
807 _uncaughtErrorMessage = null; 810 _uncaughtErrorMessage = null;
808 811
809 if (_config == null) { 812 if (_config == null) {
810 _config = new Configuration(); 813 unittestConfiguration = new Configuration();
811 } 814 }
812 _config.onInit(); 815 _config.onInit();
813 816
814 if (_config.autoStart) { 817 if (_config.autoStart) {
815 // Immediately queue the suite up. It will run after a timeout (i.e. after 818 // Immediately queue the suite up. It will run after a timeout (i.e. after
816 // main() has returned). 819 // main() has returned).
817 _defer(runTests); 820 _defer(runTests);
818 } 821 }
819 } 822 }
820 823
(...skipping 23 matching lines...) Expand all
844 } 847 }
845 848
846 /** Enable a test by ID. */ 849 /** Enable a test by ID. */
847 void enableTest(int testId) => _setTestEnabledState(testId, true); 850 void enableTest(int testId) => _setTestEnabledState(testId, true);
848 851
849 /** Disable a test by ID. */ 852 /** Disable a test by ID. */
850 void disableTest(int testId) => _setTestEnabledState(testId, false); 853 void disableTest(int testId) => _setTestEnabledState(testId, false);
851 854
852 /** Signature for a test function. */ 855 /** Signature for a test function. */
853 typedef dynamic TestFunction(); 856 typedef dynamic TestFunction();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698