| 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 'dart:convert'; | 7 import 'dart:convert'; |
| 8 | 8 |
| 9 import 'package:path/path.dart' as p; | 9 import 'package:path/path.dart' as p; |
| 10 import 'package:scheduled_test/descriptor.dart' as d; | 10 import 'package:scheduled_test/descriptor.dart' as d; |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 test('skip 2', () {}, skip: true); | 336 test('skip 2', () {}, skip: true); |
| 337 test('skip 3', () {}, skip: true); | 337 test('skip 3', () {}, skip: true); |
| 338 """, [ | 338 """, [ |
| 339 _start, | 339 _start, |
| 340 _allSuites(), | 340 _allSuites(), |
| 341 _suite(0), | 341 _suite(0), |
| 342 _testStart(1, "loading test.dart", groupIDs: []), | 342 _testStart(1, "loading test.dart", groupIDs: []), |
| 343 _testDone(1, hidden: true), | 343 _testDone(1, hidden: true), |
| 344 _group(2, testCount: 3), | 344 _group(2, testCount: 3), |
| 345 _testStart(3, "skip 1", skip: true, line: 6, column: 9), | 345 _testStart(3, "skip 1", skip: true, line: 6, column: 9), |
| 346 _testDone(3), | 346 _testDone(3, skipped: true), |
| 347 _testStart(4, "skip 2", skip: true, line: 7, column: 9), | 347 _testStart(4, "skip 2", skip: true, line: 7, column: 9), |
| 348 _testDone(4), | 348 _testDone(4, skipped: true), |
| 349 _testStart(5, "skip 3", skip: true, line: 8, column: 9), | 349 _testStart(5, "skip 3", skip: true, line: 8, column: 9), |
| 350 _testDone(5), | 350 _testDone(5, skipped: true), |
| 351 _done() | 351 _done() |
| 352 ]); | 352 ]); |
| 353 }); | 353 }); |
| 354 | 354 |
| 355 test("reports skipped groups", () { | 355 test("reports skipped groups", () { |
| 356 _expectReport(""" | 356 _expectReport(""" |
| 357 group('skip', () { | 357 group('skip', () { |
| 358 test('success 1', () {}); | 358 test('success 1', () {}); |
| 359 test('success 2', () {}); | 359 test('success 2', () {}); |
| 360 test('success 3', () {}); | 360 test('success 3', () {}); |
| 361 }, skip: true); | 361 }, skip: true); |
| 362 """, [ | 362 """, [ |
| 363 _start, | 363 _start, |
| 364 _allSuites(), | 364 _allSuites(), |
| 365 _suite(0), | 365 _suite(0), |
| 366 _testStart(1, "loading test.dart", groupIDs: []), | 366 _testStart(1, "loading test.dart", groupIDs: []), |
| 367 _testDone(1, hidden: true), | 367 _testDone(1, hidden: true), |
| 368 _group(2, testCount: 0), | 368 _group(2, testCount: 0), |
| 369 _group(3, name: "skip", parentID: 2, skip: true, testCount: 0, | 369 _group(3, name: "skip", parentID: 2, skip: true, testCount: 0, |
| 370 line: 6, column: 9), | 370 line: 6, column: 9), |
| 371 _testStart(4, "skip", groupIDs: [2, 3], skip: true, | 371 _testStart(4, "skip", groupIDs: [2, 3], skip: true, |
| 372 line: 6, column: 9), | 372 line: 6, column: 9), |
| 373 _testDone(4), | 373 _testDone(4, skipped: true), |
| 374 _done() | 374 _done() |
| 375 ]); | 375 ]); |
| 376 }); | 376 }); |
| 377 | 377 |
| 378 test("reports the skip reason if available", () { | 378 test("reports the skip reason if available", () { |
| 379 _expectReport(""" | 379 _expectReport(""" |
| 380 test('skip 1', () {}, skip: 'some reason'); | 380 test('skip 1', () {}, skip: 'some reason'); |
| 381 test('skip 2', () {}, skip: 'or another'); | 381 test('skip 2', () {}, skip: 'or another'); |
| 382 """, [ | 382 """, [ |
| 383 _start, | 383 _start, |
| 384 _allSuites(), | 384 _allSuites(), |
| 385 _suite(0), | 385 _suite(0), |
| 386 _testStart(1, "loading test.dart", groupIDs: []), | 386 _testStart(1, "loading test.dart", groupIDs: []), |
| 387 _testDone(1, hidden: true), | 387 _testDone(1, hidden: true), |
| 388 _group(2, testCount: 2), | 388 _group(2, testCount: 2), |
| 389 _testStart(3, "skip 1", skip: "some reason", line: 6, column: 9), | 389 _testStart(3, "skip 1", skip: "some reason", line: 6, column: 9), |
| 390 _testDone(3), | 390 _testDone(3, skipped: true), |
| 391 _testStart(4, "skip 2", skip: "or another", line: 7, column: 9), | 391 _testStart(4, "skip 2", skip: "or another", line: 7, column: 9), |
| 392 _testDone(4), | 392 _testDone(4, skipped: true), |
| 393 _done() | 393 _done() |
| 394 ]); | 394 ]); |
| 395 }); | 395 }); |
| 396 }); | 396 }); |
| 397 | 397 |
| 398 group("reports line and column numbers for", () { | 398 group("reports line and column numbers for", () { |
| 399 test("the first call to setUpAll()", () { | 399 test("the first call to setUpAll()", () { |
| 400 _expectReport(""" | 400 _expectReport(""" |
| 401 setUpAll(() {}); | 401 setUpAll(() {}); |
| 402 setUpAll(() {}); | 402 setUpAll(() {}); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 }; | 624 }; |
| 625 } | 625 } |
| 626 | 626 |
| 627 /// Returns the event emitted by the JSON reporter indicating that a test | 627 /// Returns the event emitted by the JSON reporter indicating that a test |
| 628 /// finished. | 628 /// finished. |
| 629 /// | 629 /// |
| 630 /// The [result] parameter indicates the result of the test. It defaults to | 630 /// The [result] parameter indicates the result of the test. It defaults to |
| 631 /// `"success"`. | 631 /// `"success"`. |
| 632 /// | 632 /// |
| 633 /// The [hidden] parameter indicates whether the test should not be displayed | 633 /// The [hidden] parameter indicates whether the test should not be displayed |
| 634 /// after finishing. | 634 /// after finishing. The [skipped] parameter indicates whether the test was |
| 635 Map _testDone(int id, {String result, bool hidden: false}) { | 635 /// skipped. |
| 636 Map _testDone(int id, {String result, bool hidden: false, |
| 637 bool skipped: false}) { |
| 636 result ??= "success"; | 638 result ??= "success"; |
| 637 return {"type": "testDone", "testID": id, "result": result, "hidden": hidden}; | 639 return { |
| 640 "type": "testDone", |
| 641 "testID": id, |
| 642 "result": result, |
| 643 "hidden": hidden, |
| 644 "skipped": skipped |
| 645 }; |
| 638 } | 646 } |
| 639 | 647 |
| 640 /// Returns the event emitted by the JSON reporter indicating that the entire | 648 /// Returns the event emitted by the JSON reporter indicating that the entire |
| 641 /// run finished. | 649 /// run finished. |
| 642 Map _done({bool success: true}) => {"type": "done", "success": success}; | 650 Map _done({bool success: true}) => {"type": "done", "success": success}; |
| 643 | 651 |
| 644 /// Returns the serialized metadata corresponding to [skip]. | 652 /// Returns the serialized metadata corresponding to [skip]. |
| 645 Map _metadata({skip}) { | 653 Map _metadata({skip}) { |
| 646 if (skip == true) { | 654 if (skip == true) { |
| 647 return {"skip": true, "skipReason": null}; | 655 return {"skip": true, "skipReason": null}; |
| 648 } else if (skip is String) { | 656 } else if (skip is String) { |
| 649 return {"skip": true, "skipReason": skip}; | 657 return {"skip": true, "skipReason": skip}; |
| 650 } else { | 658 } else { |
| 651 return {"skip": false, "skipReason": null}; | 659 return {"skip": false, "skipReason": null}; |
| 652 } | 660 } |
| 653 } | 661 } |
| OLD | NEW |