| 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 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] | 6 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] |
| 7 * and assumes unittest defines the type [TestFunction]. | 7 * and assumes unittest defines the type [TestFunction]. |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 /** Summarizes information about a single test case. */ | 10 /** Summarizes information about a single test case. */ |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 /** | 33 /** |
| 34 * Remaining number of callbacks functions that must reach a 'done' state | 34 * Remaining number of callbacks functions that must reach a 'done' state |
| 35 * to wait for before the test completes. | 35 * to wait for before the test completes. |
| 36 */ | 36 */ |
| 37 int callbackFunctionsOutstanding; | 37 int callbackFunctionsOutstanding; |
| 38 | 38 |
| 39 /** Error or failure message. */ | 39 /** Error or failure message. */ |
| 40 String message = ''; | 40 String message = ''; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * One of [_PASS], [_FAIL], [_ERROR], or [null] if the test hasn't run yet. | 43 * One of [PASS], [FAIL], [ERROR], or [null] if the test hasn't run yet. |
| 44 */ | 44 */ |
| 45 String result; | 45 String result; |
| 46 | 46 |
| 47 /** Stack trace associated with this test, or null if it succeeded. */ | 47 /** Stack trace associated with this test, or null if it succeeded. */ |
| 48 String stackTrace; | 48 String stackTrace; |
| 49 | 49 |
| 50 /** The group (or groups) under which this test is running. */ | 50 /** The group (or groups) under which this test is running. */ |
| 51 final String currentGroup; | 51 final String currentGroup; |
| 52 | 52 |
| 53 Date startTime; | 53 Date startTime; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (!_doneTeardown) { | 91 if (!_doneTeardown) { |
| 92 if (_tearDown != null) { | 92 if (_tearDown != null) { |
| 93 _tearDown(); | 93 _tearDown(); |
| 94 } | 94 } |
| 95 _doneTeardown = true; | 95 _doneTeardown = true; |
| 96 } | 96 } |
| 97 _config.onTestResult(this); | 97 _config.onTestResult(this); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void pass() { | 100 void pass() { |
| 101 result = _PASS; | 101 result = PASS; |
| 102 _complete(); | 102 _complete(); |
| 103 } | 103 } |
| 104 | 104 |
| 105 void fail(String messageText, String stack) { | 105 void fail(String messageText, String stack) { |
| 106 if (result != null) { | 106 if (result != null) { |
| 107 if (result == _PASS) { | 107 if (result == PASS) { |
| 108 error('Test failed after initially passing: $messageText', stack); | 108 error('Test failed after initially passing: $messageText', stack); |
| 109 } else if (result == _FAIL) { | 109 } else if (result == FAIL) { |
| 110 error('Test failed more than once: $messageText', stack); | 110 error('Test failed more than once: $messageText', stack); |
| 111 } | 111 } |
| 112 } else { | 112 } else { |
| 113 result = _FAIL; | 113 result = FAIL; |
| 114 message = messageText; | 114 message = messageText; |
| 115 stackTrace = stack; | 115 stackTrace = stack; |
| 116 _complete(); | 116 _complete(); |
| 117 } | 117 } |
| 118 } | 118 } |
| 119 | 119 |
| 120 void error(String messageText, String stack) { | 120 void error(String messageText, String stack) { |
| 121 result = _ERROR; | 121 result = ERROR; |
| 122 message = messageText; | 122 message = messageText; |
| 123 stackTrace = stack; | 123 stackTrace = stack; |
| 124 _complete(); | 124 _complete(); |
| 125 } | 125 } |
| 126 } | 126 } |
| OLD | NEW |