OLD | NEW |
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 'package:scheduled_test/descriptor.dart' as d; | 7 import 'package:scheduled_test/descriptor.dart' as d; |
8 import 'package:scheduled_test/scheduled_stream.dart'; | 8 import 'package:scheduled_test/scheduled_stream.dart'; |
9 import 'package:scheduled_test/scheduled_test.dart'; | 9 import 'package:scheduled_test/scheduled_test.dart'; |
10 | 10 |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 }); | 252 }); |
253 | 253 |
254 test("displays a skipped group", () { | 254 test("displays a skipped group", () { |
255 _expectReport(""" | 255 _expectReport(""" |
256 group('skip', () { | 256 group('skip', () { |
257 test('test 1', () {}); | 257 test('test 1', () {}); |
258 test('test 2', () {}); | 258 test('test 2', () {}); |
259 test('test 3', () {}); | 259 test('test 3', () {}); |
260 }, skip: true);""", | 260 }, skip: true);""", |
261 """ | 261 """ |
262 +0: skip | 262 +0: skip test 1 |
263 +0 ~1: All tests skipped."""); | 263 +0 ~1: skip test 2 |
| 264 +0 ~2: skip test 3 |
| 265 +0 ~3: All tests skipped."""); |
264 }); | 266 }); |
265 | 267 |
266 test("runs skipped tests along with successful tests", () { | 268 test("runs skipped tests along with successful tests", () { |
267 _expectReport(""" | 269 _expectReport(""" |
268 test('skip 1', () {}, skip: true); | 270 test('skip 1', () {}, skip: true); |
269 test('success 1', () {}); | 271 test('success 1', () {}); |
270 test('skip 2', () {}, skip: true); | 272 test('skip 2', () {}, skip: true); |
271 test('success 2', () {});""", | 273 test('success 2', () {});""", |
272 """ | 274 """ |
273 +0: skip 1 | 275 +0: skip 1 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 _expectReport(""" | 309 _expectReport(""" |
308 test('skip 1', () {}, skip: 'some reason'); | 310 test('skip 1', () {}, skip: 'some reason'); |
309 test('skip 2', () {}, skip: 'or another');""", | 311 test('skip 2', () {}, skip: 'or another');""", |
310 """ | 312 """ |
311 +0: skip 1 | 313 +0: skip 1 |
312 Skip: some reason | 314 Skip: some reason |
313 +0 ~1: skip 2 | 315 +0 ~1: skip 2 |
314 Skip: or another | 316 Skip: or another |
315 +0 ~2: All tests skipped."""); | 317 +0 ~2: All tests skipped."""); |
316 }); | 318 }); |
| 319 |
| 320 test("runs skipped tests with --run-skipped", () { |
| 321 _expectReport(""" |
| 322 test('skip 1', () {}, skip: 'some reason'); |
| 323 test('skip 2', () {}, skip: 'or another');""", |
| 324 """ |
| 325 +0: skip 1 |
| 326 +1: skip 2 |
| 327 +2: All tests passed!""", |
| 328 args: ["--run-skipped"]); |
| 329 }); |
317 }); | 330 }); |
318 } | 331 } |
319 | 332 |
320 void _expectReport(String tests, String expected) { | 333 void _expectReport(String tests, String expected, {List<String> args}) { |
321 var dart = """ | 334 var dart = """ |
322 import 'dart:async'; | 335 import 'dart:async'; |
323 | 336 |
324 import 'package:test/test.dart'; | 337 import 'package:test/test.dart'; |
325 | 338 |
326 void main() { | 339 void main() { |
327 $tests | 340 $tests |
328 } | 341 } |
329 """; | 342 """; |
330 | 343 |
331 d.file("test.dart", dart).create(); | 344 d.file("test.dart", dart).create(); |
332 | 345 |
333 var test = runTest(["test.dart"]); | 346 var test = runTest(["test.dart"]..addAll(args ?? [])); |
334 test.shouldExit(); | 347 test.shouldExit(); |
335 | 348 |
336 schedule(() async { | 349 schedule(() async { |
337 var stdoutLines = await test.stdoutStream().toList(); | 350 var stdoutLines = await test.stdoutStream().toList(); |
338 | 351 |
339 // Remove excess trailing whitespace and trim off timestamps. | 352 // Remove excess trailing whitespace and trim off timestamps. |
340 var actual = stdoutLines.map((line) { | 353 var actual = stdoutLines.map((line) { |
341 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); | 354 if (line.startsWith(" ") || line.isEmpty) return line.trimRight(); |
342 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); | 355 return line.trim().replaceFirst(new RegExp("^[0-9]{2}:[0-9]{2} "), ""); |
343 }).join("\n"); | 356 }).join("\n"); |
344 | 357 |
345 // Un-indent the expected string. | 358 // Un-indent the expected string. |
346 var indentation = expected.indexOf(new RegExp("[^ ]")); | 359 var indentation = expected.indexOf(new RegExp("[^ ]")); |
347 expected = expected.split("\n").map((line) { | 360 expected = expected.split("\n").map((line) { |
348 if (line.isEmpty) return line; | 361 if (line.isEmpty) return line; |
349 return line.substring(indentation); | 362 return line.substring(indentation); |
350 }).join("\n"); | 363 }).join("\n"); |
351 | 364 |
352 expect(actual, equals(expected)); | 365 expect(actual, equals(expected)); |
353 }); | 366 }); |
354 } | 367 } |
OLD | NEW |