| 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); | |
| 57 _currentTestCase = testCase; | 55 _currentTestCase = testCase; |
| 58 } | 56 } |
| 59 | 57 |
| 60 /** | 58 /** |
| 61 * Called when each test is completed. Useful to show intermediate progress on | 59 * Called when each test is completed. Useful to show intermediate progress on |
| 62 * a test suite. | 60 * a test suite. |
| 63 */ | 61 */ |
| 64 void onTestResult(TestCase testCase) { | 62 void onTestResult(TestCase testCase) { |
| 65 assert(testCase != null); | |
| 66 assert(_currentTestCase == testCase); | |
| 67 _currentTestCase = null; | 63 _currentTestCase = null; |
| 68 } | 64 } |
| 69 | 65 |
| 70 /** | 66 /** |
| 71 * Can be called by tests to log status. Tests should use this | 67 * Can be called by tests to log status. Tests should use this |
| 72 * instead of print. Subclasses should not override this; they | 68 * instead of print. Subclasses should not override this; they |
| 73 * should instead override logMessage which is passed the test case. | 69 * should instead override logMessage which is passed the test case. |
| 74 */ | 70 */ |
| 75 void logMessage(String message) { | 71 void logMessage(String message) { |
| 76 if (currentTestCase == null || _currentTest >= _tests.length || | 72 if (currentTestCase == null || _currentTest >= _tests.length || |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 // Currently e.message works in dartium, but not in dartc. | 157 // Currently e.message works in dartium, but not in dartc. |
| 162 handleExternalError(e, String message) => | 158 handleExternalError(e, String message) => |
| 163 _reportTestError('$message\nCaught $e', ''); | 159 _reportTestError('$message\nCaught $e', ''); |
| 164 | 160 |
| 165 _postMessage(String message) { | 161 _postMessage(String message) { |
| 166 // In dart2js browser tests, the JavaScript-based test controller | 162 // In dart2js browser tests, the JavaScript-based test controller |
| 167 // intercepts calls to print and listens for "secret" messages. | 163 // intercepts calls to print and listens for "secret" messages. |
| 168 print(message); | 164 print(message); |
| 169 } | 165 } |
| 170 } | 166 } |
| OLD | NEW |