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

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

Issue 13261006: pkg/unittest: cleanup to logMessage (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nit Created 7 years, 8 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 */ 178 */
179 void set unittestConfiguration(Configuration value) { 179 void set unittestConfiguration(Configuration value) {
180 if(!identical(_config, value)) { 180 if(!identical(_config, value)) {
181 if(_config != null) { 181 if(_config != null) {
182 throw new StateError('unittestConfiguration has already been set'); 182 throw new StateError('unittestConfiguration has already been set');
183 } 183 }
184 _config = value; 184 _config = value;
185 } 185 }
186 } 186 }
187 187
188 void logMessage(String message) => _config.logMessage(message); 188 /**
kevmoo-old 2013/03/29 02:19:25 Call the corresponding logTestCaseMessage on the c
189 * Can be called by tests to log status. Tests should use this
190 * instead of [print].
191 */
192 void logMessage(String message) =>
193 _config.logTestCaseMessage(currentTestCase, message);
189 194
190 /** 195 /**
191 * Description text of the current test group. If multiple groups are nested, 196 * Description text of the current test group. If multiple groups are nested,
192 * this will contain all of their text concatenated. 197 * this will contain all of their text concatenated.
193 */ 198 */
194 String _currentGroup = ''; 199 String _currentGroup = '';
195 200
196 /** Separator used between group names and test names. */ 201 /** Separator used between group names and test names. */
197 String groupSep = ' '; 202 String groupSep = ' ';
198 203
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 int failed = 0; 783 int failed = 0;
779 int errors = 0; 784 int errors = 0;
780 785
781 for (TestCase t in _testCases) { 786 for (TestCase t in _testCases) {
782 switch (t.result) { 787 switch (t.result) {
783 case PASS: passed++; break; 788 case PASS: passed++; break;
784 case FAIL: failed++; break; 789 case FAIL: failed++; break;
785 case ERROR: errors++; break; 790 case ERROR: errors++; break;
786 } 791 }
787 } 792 }
788 _config.onSummary(passed, failed, errors, _testCases, _uncaughtErrorMessage); 793 _config.onSummary(passed, failed, errors, testCases, _uncaughtErrorMessage);
kevmoo-old 2013/03/29 02:19:25 Tiny nit. Pass onSummary the immutable view of tes
789 _config.onDone(passed > 0 && failed == 0 && errors == 0 && 794 _config.onDone(passed > 0 && failed == 0 && errors == 0 &&
790 _uncaughtErrorMessage == null); 795 _uncaughtErrorMessage == null);
791 _initialized = false; 796 _initialized = false;
792 } 797 }
793 798
794 String _fullSpec(String spec) { 799 String _fullSpec(String spec) {
795 if (spec == null) return '$_currentGroup'; 800 if (spec == null) return '$_currentGroup';
796 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec; 801 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec;
797 } 802 }
798 803
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
847 } 852 }
848 853
849 /** Enable a test by ID. */ 854 /** Enable a test by ID. */
850 void enableTest(int testId) => _setTestEnabledState(testId, true); 855 void enableTest(int testId) => _setTestEnabledState(testId, true);
851 856
852 /** Disable a test by ID. */ 857 /** Disable a test by ID. */
853 void disableTest(int testId) => _setTestEnabledState(testId, false); 858 void disableTest(int testId) => _setTestEnabledState(testId, false);
854 859
855 /** Signature for a test function. */ 860 /** Signature for a test function. */
856 typedef dynamic TestFunction(); 861 typedef dynamic TestFunction();
OLDNEW
« pkg/unittest/lib/src/config.dart ('K') | « pkg/unittest/lib/src/config.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698