@@ -26,6 +26,11 @@ const FailingTest failingTest = const FailingTest();
26
26
*/
27
27
const _ReflectiveTest reflectiveTest = const _ReflectiveTest ();
28
28
29
+ /**
30
+ * A marker annotation used to annotate test methods that should be skipped.
31
+ */
32
+ const SkippedTest skippedTest = const SkippedTest ();
33
+
29
34
/**
30
35
* A marker annotation used to annotate "solo" groups and tests.
31
36
*/
@@ -115,14 +120,18 @@ void defineReflectiveTests(Type type) {
115
120
_hasAnnotationInstance (memberMirror, soloTest);
116
121
// test_
117
122
if (memberName.startsWith ('test_' )) {
118
- group.addTest (isSolo, memberName, memberMirror, () {
119
- if (_hasFailingTestAnnotation (memberMirror) ||
120
- _isCheckedMode && _hasAssertFailingTestAnnotation (memberMirror)) {
121
- return _runFailingTest (classMirror, symbol);
122
- } else {
123
- return _runTest (classMirror, symbol);
124
- }
125
- });
123
+ if (_hasSkippedTestAnnotation (memberMirror)) {
124
+ group.addSkippedTest (memberName);
125
+ } else {
126
+ group.addTest (isSolo, memberName, memberMirror, () {
127
+ if (_hasFailingTestAnnotation (memberMirror) ||
128
+ _isCheckedMode && _hasAssertFailingTestAnnotation (memberMirror)) {
129
+ return _runFailingTest (classMirror, symbol);
130
+ } else {
131
+ return _runTest (classMirror, symbol);
132
+ }
133
+ });
134
+ }
126
135
return ;
127
136
}
128
137
// solo_test_
@@ -143,6 +152,10 @@ void defineReflectiveTests(Type type) {
143
152
return _runFailingTest (classMirror, symbol);
144
153
});
145
154
}
155
+ // skip_test_
156
+ if (memberName.startsWith ('skip_test_' )) {
157
+ group.addSkippedTest (memberName);
158
+ }
146
159
});
147
160
148
161
// Support for the case of missing enclosing [defineReflectiveSuite].
@@ -160,7 +173,7 @@ void _addTestsIfTopLevelSuite() {
160
173
for (_Test test in group.tests) {
161
174
if (allTests || test.isSolo) {
162
175
test_package.test (test.name, test.function,
163
- timeout: test.timeout);
176
+ timeout: test.timeout, skip : test.isSkipped );
164
177
}
165
178
}
166
179
}
@@ -211,6 +224,9 @@ bool _hasAssertFailingTestAnnotation(MethodMirror method) =>
211
224
bool _hasFailingTestAnnotation (MethodMirror method) =>
212
225
_hasAnnotationInstance (method, failingTest);
213
226
227
+ bool _hasSkippedTestAnnotation (MethodMirror method) =>
228
+ _hasAnnotationInstance (method, skippedTest);
229
+
214
230
Future _invokeSymbolIfExists (InstanceMirror instanceMirror, Symbol symbol) {
215
231
var invocationResult = null ;
216
232
InstanceMirror closure;
@@ -276,6 +292,19 @@ class FailingTest {
276
292
const FailingTest ({String issue, String reason});
277
293
}
278
294
295
+ /**
296
+ * A marker annotation used to annotate test methods which are skipped.
297
+ */
298
+ class SkippedTest {
299
+ /**
300
+ * Initialize this annotation with the given arguments.
301
+ *
302
+ * [issue] is a full URI describing the failure and used for tracking.
303
+ * [reason] is a free form textual description.
304
+ */
305
+ const SkippedTest ({String issue, String reason});
306
+ }
307
+
279
308
/**
280
309
* A marker annotation used to annotate test methods with additional timeout
281
310
* information.
@@ -309,6 +338,11 @@ class _Group {
309
338
310
339
bool get hasSoloTest => tests.any ((test) => test.isSolo);
311
340
341
+ void addSkippedTest (String name) {
342
+ String fullName = _combineNames (this .name, name);
343
+ tests.add (new _Test .skipped (isSolo, fullName));
344
+ }
345
+
312
346
void addTest (bool isSolo, String name, MethodMirror memberMirror,
313
347
_TestFunction function) {
314
348
String fullName = _combineNames (this .name, name);
@@ -341,5 +375,13 @@ class _Test {
341
375
final _TestFunction function;
342
376
final test_package.Timeout timeout;
343
377
344
- _Test (this .isSolo, this .name, this .function, this .timeout);
378
+ final bool isSkipped;
379
+
380
+ _Test (this .isSolo, this .name, this .function, this .timeout)
381
+ : isSkipped = false ;
382
+
383
+ _Test .skipped (this .isSolo, this .name)
384
+ : isSkipped = true ,
385
+ function = null ,
386
+ timeout = null ;
345
387
}
0 commit comments