OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 /** |
| 6 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] |
| 7 * and assumes unittest defines the type [TestFunction]. |
| 8 */ |
| 9 |
| 10 /** Summarizes information about a single test case. */ |
| 11 class TestCase { |
| 12 /** Identifier for this test. */ |
| 13 final int id; |
| 14 |
| 15 /** A description of what the test is specifying. */ |
| 16 final String description; |
| 17 |
| 18 /** The body of the test case. */ |
| 19 final TestFunction test; |
| 20 |
| 21 /** Total number of callbacks to wait for before the test completes. */ |
| 22 int callbacks; |
| 23 |
| 24 /** Error or failure message. */ |
| 25 String message = ''; |
| 26 |
| 27 /** |
| 28 * One of [_PASS], [_FAIL], or [_ERROR] or [null] if the test hasn't run yet. |
| 29 */ |
| 30 String result; |
| 31 |
| 32 /** Stack trace associated with this test, or null if it succeeded. */ |
| 33 String stackTrace; |
| 34 |
| 35 Date startTime; |
| 36 |
| 37 Duration runningTime; |
| 38 |
| 39 TestCase(this.id, this.description, this.test, this.callbacks); |
| 40 |
| 41 bool get isComplete() => result != null; |
| 42 |
| 43 void pass() { |
| 44 result = _PASS; |
| 45 } |
| 46 |
| 47 void fail(String message, String stackTrace) { |
| 48 result = _FAIL; |
| 49 this.message = message; |
| 50 this.stackTrace = stackTrace; |
| 51 } |
| 52 |
| 53 void error(String message, String stackTrace) { |
| 54 result = _ERROR; |
| 55 this.message = message; |
| 56 this.stackTrace = stackTrace; |
| 57 } |
| 58 } |
| 59 |
| 60 |
OLD | NEW |