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

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

Issue 772463003: Don't Throw Error when setting unittest config twice (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Adding new version 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
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 /// Support for writing Dart unit tests. 5 /// Support for writing Dart unit tests.
6 /// 6 ///
7 /// For information on installing and importing this library, see the 7 /// For information on installing and importing this library, see the
8 /// [unittest package on pub.dartlang.org] 8 /// [unittest package on pub.dartlang.org]
9 /// (http://pub.dartlang.org/packages/unittest). 9 /// (http://pub.dartlang.org/packages/unittest).
10 /// 10 ///
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 } 187 }
188 return _config; 188 return _config;
189 } 189 }
190 190
191 /// Sets the [Configuration] used by the unittest library. 191 /// Sets the [Configuration] used by the unittest library.
192 /// 192 ///
193 /// Throws a [StateError] if there is an existing, incompatible value. 193 /// Throws a [StateError] if there is an existing, incompatible value.
194 void set unittestConfiguration(Configuration value) { 194 void set unittestConfiguration(Configuration value) {
195 if (!identical(_config, value)) { 195 if (!identical(_config, value)) {
196 if (_config != null) { 196 if (_config != null) {
197 throw new StateError('unittestConfiguration has already been set'); 197 logMessage('Warning: The unittestConfiguration has already been set. New '
198 + 'unittestConfiguration ignored.');
kevmoo 2014/12/08 21:04:46 Remove '+' adjacent string literals automatically
Nicolas Garnier 2014/12/08 21:18:15 Done.
199 return;
kevmoo 2014/12/08 21:04:45 Use an else block instead of the in-block return
Nicolas Garnier 2014/12/08 21:18:15 Done.
198 } 200 }
199 _config = value; 201 _config = value;
200 } 202 }
201 } 203 }
202 204
203 /// Can be called by tests to log status. Tests should use this 205 /// Can be called by tests to log status. Tests should use this
204 /// instead of [print]. 206 /// instead of [print].
205 void logMessage(String message) => 207 void logMessage(String message) =>
206 _config.onLogMessage(currentTestCase, message); 208 _config.onLogMessage(currentTestCase, message);
207 209
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 /// 592 ///
591 /// This allows for multiple invocations of the unittest library in the same 593 /// This allows for multiple invocations of the unittest library in the same
592 /// application instance. 594 /// application instance.
593 /// This is useful when, for example, creating a test runner application which 595 /// This is useful when, for example, creating a test runner application which
594 /// needs to create a new pristine test environment on each invocation to run 596 /// needs to create a new pristine test environment on each invocation to run
595 /// a given set of test. 597 /// a given set of test.
596 dynamic withTestEnvironment(callback()) { 598 dynamic withTestEnvironment(callback()) {
597 return runZoned(callback, 599 return runZoned(callback,
598 zoneValues: {_UNITTEST_ENVIRONMENT: new _TestEnvironment()}); 600 zoneValues: {_UNITTEST_ENVIRONMENT: new _TestEnvironment()});
599 } 601 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698