Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: test/runner/compact_reporter_test.dart

Issue 1093633004: Add test- and group-level support for skipping tests. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/test.dart ('k') | test/runner/engine_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 @TestOn("vm") 5 @TestOn("vm")
6 6
7 import 'dart:io'; 7 import 'dart:io';
8 8
9 import 'package:path/path.dart' as p; 9 import 'package:path/path.dart' as p;
10 import 'package:test/src/util/io.dart'; 10 import 'package:test/src/util/io.dart';
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 test.dart 10:11 main.<fn> 223 test.dart 10:11 main.<fn>
224 224
225 five 225 five
226 six 226 six
227 227
228 +0 -1: wait 228 +0 -1: wait
229 +1 -1: wait 229 +1 -1: wait
230 +1 -1: Some tests failed."""); 230 +1 -1: Some tests failed.""");
231 }); 231 });
232 }); 232 });
233
234 group("skip:", () {
235 test("displays skipped tests separately", () {
236 _expectReport("""
237 test('skip 1', () {}, skip: true);
238 test('skip 2', () {}, skip: true);
239 test('skip 3', () {}, skip: true);""",
240 """
241 +0: skip 1
242 +0 ~1: skip 1
243 +0 ~1: skip 2
244 +0 ~2: skip 2
245 +0 ~2: skip 3
246 +0 ~3: skip 3
247 +0 ~3: All tests skipped.""");
248 });
249
250 test("runs skipped tests along with successful tests", () {
251 _expectReport("""
252 test('skip 1', () {}, skip: true);
253 test('success 1', () {});
254 test('skip 2', () {}, skip: true);
255 test('success 2', () {});""",
256 """
257 +0: skip 1
258 +0 ~1: skip 1
259 +0 ~1: success 1
260 +1 ~1: success 1
261 +1 ~1: skip 2
262 +1 ~2: skip 2
263 +1 ~2: success 2
264 +2 ~2: success 2
265 +2 ~2: All tests passed!""");
266 });
267
268 test("runs skipped tests along with successful and failing tests", () {
269 _expectReport("""
270 test('failure 1', () => throw new TestFailure('oh no'));
271 test('skip 1', () {}, skip: true);
272 test('success 1', () {});
273 test('failure 2', () => throw new TestFailure('oh no'));
274 test('skip 2', () {}, skip: true);
275 test('success 2', () {});""",
276 """
277 +0: failure 1
278 +0 -1: failure 1
279 oh no
280 test.dart 6:35 main.<fn>
281
282
283 +0 -1: skip 1
284 +0 ~1 -1: skip 1
285 +0 ~1 -1: success 1
286 +1 ~1 -1: success 1
287 +1 ~1 -1: failure 2
288 +1 ~1 -2: failure 2
289 oh no
290 test.dart 9:35 main.<fn>
291
292
293 +1 ~1 -2: skip 2
294 +1 ~2 -2: skip 2
295 +1 ~2 -2: success 2
296 +2 ~2 -2: success 2
297 +2 ~2 -2: Some tests failed.""");
298 });
299
300 test("displays the skip reason if available", () {
301 _expectReport("""
302 test('skip 1', () {}, skip: 'some reason');
303 test('skip 2', () {}, skip: 'or another');""",
304 """
305 +0: skip 1
306 +0 ~1: skip 1
307 Skip: some reason
308
309 +0 ~1: skip 2
310 +0 ~2: skip 2
311 Skip: or another
312
313 +0 ~2: All tests skipped.""");
314 });
315 });
233 } 316 }
234 317
235 void _expectReport(String tests, String expected, {List<String> args, 318 void _expectReport(String tests, String expected, {List<String> args,
236 int concurrency}) { 319 int concurrency}) {
237 if (concurrency == null) concurrency = 1; 320 if (concurrency == null) concurrency = 1;
238 321
239 var dart = """ 322 var dart = """
240 import 'dart:async'; 323 import 'dart:async';
241 324
242 import 'package:test/test.dart'; 325 import 'package:test/test.dart';
(...skipping 20 matching lines...) Expand all
263 // Un-indent the expected string. 346 // Un-indent the expected string.
264 var indentation = expected.indexOf(new RegExp("[^ ]")); 347 var indentation = expected.indexOf(new RegExp("[^ ]"));
265 expected = expected.split("\n").map((line) { 348 expected = expected.split("\n").map((line) {
266 if (line.isEmpty) return line; 349 if (line.isEmpty) return line;
267 return line.substring(indentation); 350 return line.substring(indentation);
268 }).join("\n"); 351 }).join("\n");
269 352
270 expect(actual, equals(expected)); 353 expect(actual, equals(expected));
271 }), completes); 354 }), completes);
272 } 355 }
OLDNEW
« no previous file with comments | « lib/test.dart ('k') | test/runner/engine_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698