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

Side by Side Diff: test/backend/declarer_test.dart

Issue 1405633004: feature: tag tests; choose tags on command line Base URL: git@github.com:yjbanov/test.git@tags
Patch Set: address comments Created 5 years 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/backend/metadata_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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:test/src/backend/group.dart'; 7 import 'package:test/src/backend/group.dart';
8 import 'package:test/src/backend/invoker.dart'; 8 import 'package:test/src/backend/invoker.dart';
9 import 'package:test/src/backend/suite.dart'; 9 import 'package:test/src/backend/suite.dart';
10 import 'package:test/src/backend/test.dart'; 10 import 'package:test/src/backend/test.dart';
(...skipping 30 matching lines...) Expand all
41 test("description 1", () {}); 41 test("description 1", () {});
42 test("description 2", () {}); 42 test("description 2", () {});
43 test("description 3", () {}); 43 test("description 3", () {});
44 }); 44 });
45 45
46 expect(tests, hasLength(3)); 46 expect(tests, hasLength(3));
47 expect(tests[0].name, equals("description 1")); 47 expect(tests[0].name, equals("description 1"));
48 expect(tests[1].name, equals("description 2")); 48 expect(tests[1].name, equals("description 2"));
49 expect(tests[2].name, equals("description 3")); 49 expect(tests[2].name, equals("description 3"));
50 }); 50 });
51
52 test("declares a test with tags", () {
53 var tests = declare(() {
54 test("tags as String", () {}, tags: "a");
55 test("tags as List", () {}, tags: ["a", "b"]);
56 test("tags as null", () {}, tags: null);
57 });
58
59 expect(tests, hasLength(3));
60 expect(tests[0].metadata.tags, unorderedEquals(["a"]));
61 expect(tests[1].metadata.tags, unorderedEquals(["a", "b"]));
62 expect(tests[2].metadata.tags, isEmpty);
63 });
64
65 test("throws on invalid tags", () {
66 expect(() {
67 declare(() {
68 test("a", () {}, tags: 1);
69 });
70 }, throwsArgumentError);
71 });
51 }); 72 });
52 73
53 group(".setUp()", () { 74 group(".setUp()", () {
54 test("is run before all tests", () async { 75 test("is run before all tests", () async {
55 var setUpRun = false; 76 var setUpRun = false;
56 var tests = declare(() { 77 var tests = declare(() {
57 setUp(() => setUpRun = true); 78 setUp(() => setUpRun = true);
58 79
59 test("description 1", expectAsync(() { 80 test("description 1", expectAsync(() {
60 expect(setUpRun, isTrue); 81 expect(setUpRun, isTrue);
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 428
408 test("description", expectAsync(() { 429 test("description", expectAsync(() {
409 expect(outerSetUpRun, isTrue); 430 expect(outerSetUpRun, isTrue);
410 expect(innerSetUpRun, isTrue); 431 expect(innerSetUpRun, isTrue);
411 }, max: 1)); 432 }, max: 1));
412 }); 433 });
413 }); 434 });
414 435
415 return _runTest(entries.single.entries.single); 436 return _runTest(entries.single.entries.single);
416 }); 437 });
438
439 test("inherits group's tags", () {
440 var tests = declare(() {
441 group("outer", () {
442 group("inner", () {
443 test("with tags", () {}, tags: "d");
444 }, tags: ["b", "c"]);
445 }, tags: "a");
446 });
447
448 var outerGroup = tests.single;
449 var innerGroup = outerGroup.entries.single;
450 var testWithTags = innerGroup.entries.single;
451 expect(outerGroup.metadata.tags, unorderedEquals(["a"]));
452 expect(innerGroup.metadata.tags, unorderedEquals(["a", "b", "c"]));
453 expect(testWithTags.metadata.tags,
454 unorderedEquals(["a", "b", "c", "d"]));
455 });
456
457 test("throws on invalid tags", () {
458 expect(() {
459 declare(() {
460 group("a", () {}, tags: 1);
461 });
462 }, throwsArgumentError);
463 });
417 }); 464 });
418 465
419 group(".tearDown()", () { 466 group(".tearDown()", () {
420 test("is scoped to the group", () async { 467 test("is scoped to the group", () async {
421 var tearDownRun; 468 var tearDownRun;
422 var entries = declare(() { 469 var entries = declare(() {
423 setUp(() => tearDownRun = false); 470 setUp(() => tearDownRun = false);
424 471
425 group("group", () { 472 group("group", () {
426 tearDown(() => tearDownRun = true); 473 tearDown(() => tearDownRun = true);
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 /// doesn't throw any invisible exceptions. 586 /// doesn't throw any invisible exceptions.
540 Future _runTest(Test test, {bool shouldFail: false}) { 587 Future _runTest(Test test, {bool shouldFail: false}) {
541 var liveTest = test.load(_suite); 588 var liveTest = test.load(_suite);
542 589
543 liveTest.onError.listen(shouldFail 590 liveTest.onError.listen(shouldFail
544 ? expectAsync((_) {}) 591 ? expectAsync((_) {})
545 : (error) => registerException(error.error, error.stackTrace)); 592 : (error) => registerException(error.error, error.stackTrace));
546 593
547 return liveTest.run(); 594 return liveTest.run();
548 } 595 }
OLDNEW
« no previous file with comments | « lib/test.dart ('k') | test/backend/metadata_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698