OLD | NEW |
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 804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 testCase.callbackFunctionsOutstanding > 0) return; | 815 testCase.callbackFunctionsOutstanding > 0) return; |
816 _currentTest++; | 816 _currentTest++; |
817 } | 817 } |
818 | 818 |
819 _completeTests(); | 819 _completeTests(); |
820 } | 820 } |
821 | 821 |
822 /** Publish results on the page and notify controller. */ | 822 /** Publish results on the page and notify controller. */ |
823 _completeTests() { | 823 _completeTests() { |
824 if (!_initialized) return; | 824 if (!_initialized) return; |
825 int testsPassed_ = 0; | 825 int passed = 0; |
826 int testsFailed_ = 0; | 826 int failed = 0; |
827 int testsErrors_ = 0; | 827 int errors = 0; |
828 | 828 |
829 for (TestCase t in _tests) { | 829 for (TestCase t in _tests) { |
830 switch (t.result) { | 830 switch (t.result) { |
831 case PASS: testsPassed_++; break; | 831 case PASS: passed++; break; |
832 case FAIL: testsFailed_++; break; | 832 case FAIL: failed++; break; |
833 case ERROR: testsErrors_++; break; | 833 case ERROR: errors++; break; |
834 } | 834 } |
835 } | 835 } |
836 _config.onDone(testsPassed_, testsFailed_, testsErrors_, _tests, | 836 _config.onSummary(passed, failed, errors, _tests, _uncaughtErrorMessage); |
837 _uncaughtErrorMessage); | 837 _config.onDone(passed > 0 && failed == 0 && errors == 0 && |
| 838 _uncaughtErrorMessage == null); |
838 _initialized = false; | 839 _initialized = false; |
839 } | 840 } |
840 | 841 |
841 String _fullSpec(String spec) { | 842 String _fullSpec(String spec) { |
842 if (spec == null) return '$_currentGroup'; | 843 if (spec == null) return '$_currentGroup'; |
843 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec; | 844 return _currentGroup != '' ? '$_currentGroup$groupSep$spec' : spec; |
844 } | 845 } |
845 | 846 |
846 void fail(String message) { | 847 void fail(String message) { |
847 throw new ExpectException(message); | 848 throw new ExpectException(message); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
900 } | 901 } |
901 | 902 |
902 /** Enable a test by ID. */ | 903 /** Enable a test by ID. */ |
903 void enableTest(int testId) => _setTestEnabledState(testId, true); | 904 void enableTest(int testId) => _setTestEnabledState(testId, true); |
904 | 905 |
905 /** Disable a test by ID. */ | 906 /** Disable a test by ID. */ |
906 void disableTest(int testId) => _setTestEnabledState(testId, false); | 907 void disableTest(int testId) => _setTestEnabledState(testId, false); |
907 | 908 |
908 /** Signature for a test function. */ | 909 /** Signature for a test function. */ |
909 typedef void TestFunction(); | 910 typedef void TestFunction(); |
OLD | NEW |