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 part of unittest; | 5 part of unittest; |
6 | 6 |
7 /** | 7 /** |
8 * Hooks to configure the unittest library for different platforms. This class | 8 * Hooks to configure the unittest library for different platforms. This class |
9 * implements the API in a platform-independent way. Tests that want to take | 9 * implements the API in a platform-independent way. Tests that want to take |
10 * advantage of the platform can create a subclass and override methods from | 10 * advantage of the platform can create a subclass and override methods from |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 } | 45 } |
46 | 46 |
47 /** Called as soon as the unittest framework starts running. */ | 47 /** Called as soon as the unittest framework starts running. */ |
48 void onStart() {} | 48 void onStart() {} |
49 | 49 |
50 /** | 50 /** |
51 * Called when each test starts. Useful to show intermediate progress on | 51 * Called when each test starts. Useful to show intermediate progress on |
52 * a test suite. | 52 * a test suite. |
53 */ | 53 */ |
54 void onTestStart(TestCase testCase) { | 54 void onTestStart(TestCase testCase) { |
| 55 assert(testCase != null); |
| 56 assert(_currentTestCase == null); |
55 _currentTestCase = testCase; | 57 _currentTestCase = testCase; |
56 } | 58 } |
57 | 59 |
58 /** | 60 /** |
59 * Called when each test is completed. Useful to show intermediate progress on | 61 * Called when each test is completed. Useful to show intermediate progress on |
60 * a test suite. | 62 * a test suite. |
61 */ | 63 */ |
62 void onTestResult(TestCase testCase) { | 64 void onTestResult(TestCase testCase) { |
| 65 assert(testCase != null); |
| 66 assert(_currentTestCase == null || _currentTestCase == testCase); |
63 _currentTestCase = null; | 67 _currentTestCase = null; |
64 } | 68 } |
65 | 69 |
66 /** | 70 /** |
67 * Can be called by tests to log status. Tests should use this | 71 * Can be called by tests to log status. Tests should use this |
68 * instead of print. Subclasses should not override this; they | 72 * instead of print. Subclasses should not override this; they |
69 * should instead override logMessage which is passed the test case. | 73 * should instead override logMessage which is passed the test case. |
70 */ | 74 */ |
71 void logMessage(String message) { | 75 void logMessage(String message) { |
72 if (currentTestCase == null || _currentTest >= _tests.length || | 76 if (currentTestCase == null || _currentTest >= _tests.length || |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // Currently e.message works in dartium, but not in dartc. | 161 // Currently e.message works in dartium, but not in dartc. |
158 handleExternalError(e, String message) => | 162 handleExternalError(e, String message) => |
159 _reportTestError('$message\nCaught $e', ''); | 163 _reportTestError('$message\nCaught $e', ''); |
160 | 164 |
161 _postMessage(String message) { | 165 _postMessage(String message) { |
162 // In dart2js browser tests, the JavaScript-based test controller | 166 // In dart2js browser tests, the JavaScript-based test controller |
163 // intercepts calls to print and listens for "secret" messages. | 167 // intercepts calls to print and listens for "secret" messages. |
164 print(message); | 168 print(message); |
165 } | 169 } |
166 } | 170 } |
OLD | NEW |