| OLD | NEW |
| 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 Loading... |
| 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.'); |
| 199 } else { |
| 200 _config = value; |
| 198 } | 201 } |
| 199 _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 |
| 208 /// Separator used between group names and test names. | 210 /// Separator used between group names and test names. |
| 209 String groupSep = ' '; | 211 String groupSep = ' '; |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| OLD | NEW |