OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 library test; | 5 library test; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 /// "browser": [ | 106 /// "browser": [ |
107 /// new Skip("TODO: add browser support"), | 107 /// new Skip("TODO: add browser support"), |
108 /// // This will be slow on browsers once it works on them. | 108 /// // This will be slow on browsers once it works on them. |
109 /// new Timeout.factor(2) | 109 /// new Timeout.factor(2) |
110 /// ] | 110 /// ] |
111 /// }); | 111 /// }); |
112 /// | 112 /// |
113 /// If multiple platforms match, the annotations apply in order as through | 113 /// If multiple platforms match, the annotations apply in order as through |
114 /// they were in nested groups. | 114 /// they were in nested groups. |
115 void test(String description, body(), {String testOn, Timeout timeout, | 115 void test(String description, body(), {String testOn, Timeout timeout, |
116 skip, Map<String, dynamic> onPlatform}) => | 116 skip, Map<String, dynamic> onPlatform, String tag, |
117 _declarer.test(description, body, | 117 List<String> tags}) => _declarer.test(description, body, |
118 testOn: testOn, timeout: timeout, skip: skip, onPlatform: onPlatform); | 118 testOn: testOn, timeout: timeout, skip: skip, |
119 onPlatform: onPlatform, tags: _deconvenienceTags(tag, tags)); | |
119 | 120 |
120 /// Creates a group of tests. | 121 /// Creates a group of tests. |
121 /// | 122 /// |
122 /// A group's description is included in the descriptions of any tests or | 123 /// A group's description is included in the descriptions of any tests or |
123 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the | 124 /// sub-groups it contains. [setUp] and [tearDown] are also scoped to the |
124 /// containing group. | 125 /// containing group. |
125 /// | 126 /// |
126 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will | 127 /// If [testOn] is passed, it's parsed as a [platform selector][]; the test will |
127 /// only be run on matching platforms. | 128 /// only be run on matching platforms. |
128 /// | 129 /// |
(...skipping 21 matching lines...) Expand all Loading... | |
150 /// "browser": [ | 151 /// "browser": [ |
151 /// new Skip("TODO: add browser support"), | 152 /// new Skip("TODO: add browser support"), |
152 /// // They'll be slow on browsers once it works on them. | 153 /// // They'll be slow on browsers once it works on them. |
153 /// new Timeout.factor(2) | 154 /// new Timeout.factor(2) |
154 /// ] | 155 /// ] |
155 /// }); | 156 /// }); |
156 /// | 157 /// |
157 /// If multiple platforms match, the annotations apply in order as through | 158 /// If multiple platforms match, the annotations apply in order as through |
158 /// they were in nested groups. | 159 /// they were in nested groups. |
159 void group(String description, void body(), {String testOn, Timeout timeout, | 160 void group(String description, void body(), {String testOn, Timeout timeout, |
160 skip, Map<String, dynamic> onPlatform}) => | 161 skip, Map<String, dynamic> onPlatform, String tag, |
161 _declarer.group(description, body, | 162 List<String> tags}) => _declarer.group(description, body, |
nweiz
2015/10/13 23:28:12
I'd like to just have one dynamic-typed parameter
yjbanov
2015/10/30 20:14:00
Done.
| |
162 testOn: testOn, timeout: timeout, skip: skip); | 163 testOn: testOn, timeout: timeout, skip: skip, |
164 tags: _deconvenienceTags(tag, tags)); | |
163 | 165 |
164 /// Registers a function to be run before tests. | 166 /// Registers a function to be run before tests. |
165 /// | 167 /// |
166 /// This function will be called before each test is run. [callback] may be | 168 /// This function will be called before each test is run. [callback] may be |
167 /// asynchronous; if so, it must return a [Future]. | 169 /// asynchronous; if so, it must return a [Future]. |
168 /// | 170 /// |
169 /// If this is called within a test group, it applies only to tests in that | 171 /// If this is called within a test group, it applies only to tests in that |
170 /// group. [callback] will be run after any set-up callbacks in parent groups or | 172 /// group. [callback] will be run after any set-up callbacks in parent groups or |
171 /// at the top level. | 173 /// at the top level. |
172 /// | 174 /// |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
214 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is | 216 /// prefer [tearDown], and only use [tearDOwnAll] if the callback is |
215 /// prohibitively slow. | 217 /// prohibitively slow. |
216 void tearDownAll(callback()) => _declarer.tearDownAll(callback); | 218 void tearDownAll(callback()) => _declarer.tearDownAll(callback); |
217 | 219 |
218 /// Registers an exception that was caught for the current test. | 220 /// Registers an exception that was caught for the current test. |
219 void registerException(error, [StackTrace stackTrace]) { | 221 void registerException(error, [StackTrace stackTrace]) { |
220 // This will usually forward directly to [Invoker.current.handleError], but | 222 // This will usually forward directly to [Invoker.current.handleError], but |
221 // going through the zone API allows other zones to consistently see errors. | 223 // going through the zone API allows other zones to consistently see errors. |
222 Zone.current.handleUncaughtError(error, stackTrace); | 224 Zone.current.handleUncaughtError(error, stackTrace); |
223 } | 225 } |
226 | |
227 List<String> _deconvenienceTags(String tag, List<String> tags) { | |
228 var result = const[]; | |
229 if (tag != null || (tags != null && tags.isNotEmpty)) { | |
230 result = []; | |
231 if (tag != null) result.add(tag); | |
232 if (tags != null && tags.isNotEmpty) result.addAll(tags); | |
233 } | |
234 return result; | |
235 } | |
OLD | NEW |