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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 void run() { | 69 void run() { |
70 if (enabled) { | 70 if (enabled) { |
71 result = stackTrace = null; | 71 result = stackTrace = null; |
72 message = ''; | 72 message = ''; |
73 _doneTeardown = false; | 73 _doneTeardown = false; |
74 if (_setUp != null) { | 74 if (_setUp != null) { |
75 _setUp(); | 75 _setUp(); |
76 } | 76 } |
77 _config.onTestStart(this); | 77 _config.onTestStart(this); |
| 78 startTime = new Date.now(); |
| 79 runningTime = null; |
78 test(); | 80 test(); |
79 } | 81 } |
80 } | 82 } |
81 | 83 |
82 void _complete() { | 84 void _complete() { |
| 85 if (runningTime == null) { |
| 86 runningTime = new Date.now().difference(startTime); |
| 87 } |
83 if (!_doneTeardown) { | 88 if (!_doneTeardown) { |
84 if (_tearDown != null) { | 89 if (_tearDown != null) { |
85 _tearDown(); | 90 _tearDown(); |
86 } | 91 } |
87 _doneTeardown = true; | 92 _doneTeardown = true; |
88 } | 93 } |
89 _config.onTestResult(this); | 94 _config.onTestResult(this); |
90 } | 95 } |
91 | 96 |
92 void pass() { | 97 void pass() { |
93 result = _PASS; | 98 result = _PASS; |
94 _complete(); | 99 _complete(); |
95 } | 100 } |
96 | 101 |
97 void fail(String messageText, String stack) { | 102 void fail(String messageText, String stack) { |
98 result = _FAIL; | 103 result = _FAIL; |
99 message = messageText; | 104 message = messageText; |
100 stackTrace = stack; | 105 stackTrace = stack; |
101 _complete(); | 106 _complete(); |
102 } | 107 } |
103 | 108 |
104 void error(String messageText, String stack) { | 109 void error(String messageText, String stack) { |
105 result = _ERROR; | 110 result = _ERROR; |
106 message = messageText; | 111 message = messageText; |
107 stackTrace = stack; | 112 stackTrace = stack; |
108 _complete(); | 113 _complete(); |
109 } | 114 } |
110 } | 115 } |
OLD | NEW |