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

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

Issue 12335113: Unit test changes: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: 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
« no previous file with comments | « pkg/unittest/lib/src/interfaces.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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, use the pub package manager. 8 * To import this library, use the pub package manager.
9 * Create a pubspec.yaml file in your project and add 9 * Create a pubspec.yaml file in your project and add
10 * a dependency on unittest with the following lines: 10 * a dependency on unittest with the following lines:
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 registerException(e, [trace]) { 766 registerException(e, [trace]) {
767 _registerException(_currentTest, e, trace); 767 _registerException(_currentTest, e, trace);
768 } 768 }
769 769
770 /** 770 /**
771 * Registers that an exception was caught for the current test. 771 * Registers that an exception was caught for the current test.
772 */ 772 */
773 _registerException(testNum, e, [trace]) { 773 _registerException(testNum, e, [trace]) {
774 trace = trace == null ? '' : trace.toString(); 774 trace = trace == null ? '' : trace.toString();
775 if (_tests[testNum].result == null) { 775 if (_tests[testNum].result == null) {
776 String message = (e is ExpectException) ? e.message : 'Caught $e'; 776 String message = (e is TestFailure) ? e.message : 'Caught $e';
777 _tests[testNum].fail(message, trace); 777 _tests[testNum].fail(message, trace);
778 } else { 778 } else {
779 _tests[testNum].error('Caught $e', trace); 779 _tests[testNum].error('Caught $e', trace);
780 } 780 }
781 } 781 }
782 782
783 /** 783 /**
784 * Runs a batch of tests, yielding whenever an asynchronous test starts 784 * Runs a batch of tests, yielding whenever an asynchronous test starts
785 * running. Tests will resume executing when such asynchronous test calls 785 * running. Tests will resume executing when such asynchronous test calls
786 * [done] or if it fails with an exception. 786 * [done] or if it fails with an exception.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 _uncaughtErrorMessage == null); 822 _uncaughtErrorMessage == null);
823 _initialized = false; 823 _initialized = false;
824 } 824 }
825 825
826 String _fullSpec(String spec) { 826 String _fullSpec(String spec) {
827 if (spec == null) return '$_currentGroup'; 827 if (spec == null) return '$_currentGroup';
828 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec; 828 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec;
829 } 829 }
830 830
831 void fail(String message) { 831 void fail(String message) {
832 throw new ExpectException(message); 832 throw new TestFailure(message);
833 } 833 }
834 834
835 /** 835 /**
836 * Lazily initializes the test library if not already initialized. 836 * Lazily initializes the test library if not already initialized.
837 */ 837 */
838 ensureInitialized() { 838 ensureInitialized() {
839 if (_initialized) { 839 if (_initialized) {
840 return; 840 return;
841 } 841 }
842 _initialized = true; 842 _initialized = true;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 } 884 }
885 } 885 }
886 886
887 /** Enable a test by ID. */ 887 /** Enable a test by ID. */
888 void enableTest(int testId) => _setTestEnabledState(testId, true); 888 void enableTest(int testId) => _setTestEnabledState(testId, true);
889 889
890 /** Disable a test by ID. */ 890 /** Disable a test by ID. */
891 void disableTest(int testId) => _setTestEnabledState(testId, false); 891 void disableTest(int testId) => _setTestEnabledState(testId, false);
892 892
893 /** Signature for a test function. */ 893 /** Signature for a test function. */
894 typedef void TestFunction(); 894 typedef dynamic TestFunction();
OLDNEW
« no previous file with comments | « pkg/unittest/lib/src/interfaces.dart ('k') | utils/tests/pub/test_pub.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698