| Index: test/backend/declarer_test.dart
|
| diff --git a/test/backend/declarer_test.dart b/test/backend/declarer_test.dart
|
| index 2d647aba76da4fd9f7004d89f6d67f1a2003dea6..837ced3a3dc82b470dc9d0cbd7057d0ba03c00ac 100644
|
| --- a/test/backend/declarer_test.dart
|
| +++ b/test/backend/declarer_test.dart
|
| @@ -5,192 +5,212 @@
|
| import 'dart:async';
|
|
|
| import 'package:test/src/backend/declarer.dart';
|
| +import 'package:test/src/backend/group.dart';
|
| import 'package:test/src/backend/invoker.dart';
|
| import 'package:test/src/backend/suite.dart';
|
| +import 'package:test/src/backend/test.dart';
|
| import 'package:test/src/frontend/timeout.dart';
|
| import 'package:test/test.dart';
|
|
|
| import '../utils.dart';
|
|
|
| -Declarer _declarer;
|
| Suite _suite;
|
|
|
| void main() {
|
| setUp(() {
|
| - _declarer = new Declarer();
|
| _suite = new Suite([]);
|
| });
|
|
|
| group(".test()", () {
|
| test("declares a test with a description and body", () async {
|
| var bodyRun = false;
|
| - _declarer.test("description", () {
|
| - bodyRun = true;
|
| + var tests = declare(() {
|
| + test("description", () {
|
| + bodyRun = true;
|
| + });
|
| });
|
|
|
| - expect(_declarer.tests, hasLength(1));
|
| - expect(_declarer.tests.single.name, equals("description"));
|
| + expect(tests, hasLength(1));
|
| + expect(tests.single.name, equals("description"));
|
|
|
| - await _runTest(0);
|
| + await _runTest(tests[0]);
|
| expect(bodyRun, isTrue);
|
| });
|
|
|
| test("declares multiple tests", () {
|
| - _declarer.test("description 1", () {});
|
| - _declarer.test("description 2", () {});
|
| - _declarer.test("description 3", () {});
|
| -
|
| - expect(_declarer.tests, hasLength(3));
|
| - expect(_declarer.tests[0].name, equals("description 1"));
|
| - expect(_declarer.tests[1].name, equals("description 2"));
|
| - expect(_declarer.tests[2].name, equals("description 3"));
|
| + var tests = declare(() {
|
| + test("description 1", () {});
|
| + test("description 2", () {});
|
| + test("description 3", () {});
|
| + });
|
| +
|
| + expect(tests, hasLength(3));
|
| + expect(tests[0].name, equals("description 1"));
|
| + expect(tests[1].name, equals("description 2"));
|
| + expect(tests[2].name, equals("description 3"));
|
| });
|
| });
|
|
|
| group(".setUp()", () {
|
| test("is run before all tests", () async {
|
| var setUpRun = false;
|
| - _declarer.setUp(() => setUpRun = true);
|
| + var tests = declare(() {
|
| + setUp(() => setUpRun = true);
|
|
|
| - _declarer.test("description 1", expectAsync(() {
|
| - expect(setUpRun, isTrue);
|
| - setUpRun = false;
|
| - }, max: 1));
|
| + test("description 1", expectAsync(() {
|
| + expect(setUpRun, isTrue);
|
| + setUpRun = false;
|
| + }, max: 1));
|
|
|
| - _declarer.test("description 2", expectAsync(() {
|
| - expect(setUpRun, isTrue);
|
| - setUpRun = false;
|
| - }, max: 1));
|
| + test("description 2", expectAsync(() {
|
| + expect(setUpRun, isTrue);
|
| + setUpRun = false;
|
| + }, max: 1));
|
| + });
|
|
|
| - await _runTest(0);
|
| - await _runTest(1);
|
| + await _runTest(tests[0]);
|
| + await _runTest(tests[1]);
|
| });
|
|
|
| test("can return a Future", () {
|
| var setUpRun = false;
|
| - _declarer.setUp(() {
|
| - return new Future(() => setUpRun = true);
|
| - });
|
| + var tests = declare(() {
|
| + setUp(() {
|
| + return new Future(() => setUpRun = true);
|
| + });
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(setUpRun, isTrue);
|
| - }, max: 1));
|
| + test("description", expectAsync(() {
|
| + expect(setUpRun, isTrue);
|
| + }, max: 1));
|
| + });
|
|
|
| - return _runTest(0);
|
| + return _runTest(tests.single);
|
| });
|
|
|
| test("runs in call order within a group", () async {
|
| var firstSetUpRun = false;
|
| var secondSetUpRun = false;
|
| var thirdSetUpRun = false;
|
| - _declarer.setUp(expectAsync(() async {
|
| - expect(secondSetUpRun, isFalse);
|
| - expect(thirdSetUpRun, isFalse);
|
| - firstSetUpRun = true;
|
| - }));
|
| -
|
| - _declarer.setUp(expectAsync(() async {
|
| - expect(firstSetUpRun, isTrue);
|
| - expect(thirdSetUpRun, isFalse);
|
| - secondSetUpRun = true;
|
| - }));
|
| -
|
| - _declarer.setUp(expectAsync(() async {
|
| - expect(firstSetUpRun, isTrue);
|
| - expect(secondSetUpRun, isTrue);
|
| - thirdSetUpRun = true;
|
| - }));
|
| -
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(firstSetUpRun, isTrue);
|
| - expect(secondSetUpRun, isTrue);
|
| - expect(thirdSetUpRun, isTrue);
|
| - }));
|
| -
|
| - await _runTest(0);
|
| + var tests = declare(() {
|
| + setUp(expectAsync(() async {
|
| + expect(secondSetUpRun, isFalse);
|
| + expect(thirdSetUpRun, isFalse);
|
| + firstSetUpRun = true;
|
| + }));
|
| +
|
| + setUp(expectAsync(() async {
|
| + expect(firstSetUpRun, isTrue);
|
| + expect(thirdSetUpRun, isFalse);
|
| + secondSetUpRun = true;
|
| + }));
|
| +
|
| + setUp(expectAsync(() async {
|
| + expect(firstSetUpRun, isTrue);
|
| + expect(secondSetUpRun, isTrue);
|
| + thirdSetUpRun = true;
|
| + }));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(firstSetUpRun, isTrue);
|
| + expect(secondSetUpRun, isTrue);
|
| + expect(thirdSetUpRun, isTrue);
|
| + }));
|
| + });
|
| +
|
| + await _runTest(tests.single);
|
| });
|
| });
|
|
|
| group(".tearDown()", () {
|
| test("is run after all tests", () async {
|
| var tearDownRun;
|
| - _declarer.setUp(() => tearDownRun = false);
|
| - _declarer.tearDown(() => tearDownRun = true);
|
| + var tests = declare(() {
|
| + setUp(() => tearDownRun = false);
|
| + tearDown(() => tearDownRun = true);
|
|
|
| - _declarer.test("description 1", expectAsync(() {
|
| - expect(tearDownRun, isFalse);
|
| - }, max: 1));
|
| + test("description 1", expectAsync(() {
|
| + expect(tearDownRun, isFalse);
|
| + }, max: 1));
|
|
|
| - _declarer.test("description 2", expectAsync(() {
|
| - expect(tearDownRun, isFalse);
|
| - }, max: 1));
|
| + test("description 2", expectAsync(() {
|
| + expect(tearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
|
|
| - await _runTest(0);
|
| + await _runTest(tests[0]);
|
| expect(tearDownRun, isTrue);
|
| - await _runTest(1);
|
| + await _runTest(tests[1]);
|
| expect(tearDownRun, isTrue);
|
| });
|
|
|
| test("is run after an out-of-band failure", () async {
|
| var tearDownRun;
|
| - _declarer.setUp(() => tearDownRun = false);
|
| - _declarer.tearDown(() => tearDownRun = true);
|
| + var tests = declare(() {
|
| + setUp(() => tearDownRun = false);
|
| + tearDown(() => tearDownRun = true);
|
|
|
| - _declarer.test("description 1", expectAsync(() {
|
| - Invoker.current.addOutstandingCallback();
|
| - new Future(() => throw new TestFailure("oh no"));
|
| - }, max: 1));
|
| + test("description 1", expectAsync(() {
|
| + Invoker.current.addOutstandingCallback();
|
| + new Future(() => throw new TestFailure("oh no"));
|
| + }, max: 1));
|
| + });
|
|
|
| - await _runTest(0, shouldFail: true);
|
| + await _runTest(tests.single, shouldFail: true);
|
| expect(tearDownRun, isTrue);
|
| });
|
|
|
| test("can return a Future", () async {
|
| var tearDownRun = false;
|
| - _declarer.tearDown(() {
|
| - return new Future(() => tearDownRun = true);
|
| - });
|
| + var tests = declare(() {
|
| + tearDown(() {
|
| + return new Future(() => tearDownRun = true);
|
| + });
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(tearDownRun, isFalse);
|
| - }, max: 1));
|
| + test("description", expectAsync(() {
|
| + expect(tearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
|
|
| - await _runTest(0);
|
| + await _runTest(tests.single);
|
| expect(tearDownRun, isTrue);
|
| });
|
|
|
| test("isn't run until there are no outstanding callbacks", () async {
|
| var outstandingCallbackRemoved = false;
|
| var outstandingCallbackRemovedBeforeTeardown = false;
|
| - _declarer.tearDown(() {
|
| - outstandingCallbackRemovedBeforeTeardown = outstandingCallbackRemoved;
|
| - });
|
| + var tests = declare(() {
|
| + tearDown(() {
|
| + outstandingCallbackRemovedBeforeTeardown = outstandingCallbackRemoved;
|
| + });
|
|
|
| - _declarer.test("description", () {
|
| - Invoker.current.addOutstandingCallback();
|
| - pumpEventQueue().then((_) {
|
| - outstandingCallbackRemoved = true;
|
| - Invoker.current.removeOutstandingCallback();
|
| + test("description", () {
|
| + Invoker.current.addOutstandingCallback();
|
| + pumpEventQueue().then((_) {
|
| + outstandingCallbackRemoved = true;
|
| + Invoker.current.removeOutstandingCallback();
|
| + });
|
| });
|
| });
|
|
|
| - await _runTest(0);
|
| + await _runTest(tests.single);
|
| expect(outstandingCallbackRemovedBeforeTeardown, isTrue);
|
| });
|
|
|
| test("doesn't complete until there are no outstanding callbacks", () async {
|
| var outstandingCallbackRemoved = false;
|
| - _declarer.tearDown(() {
|
| - Invoker.current.addOutstandingCallback();
|
| - pumpEventQueue().then((_) {
|
| - outstandingCallbackRemoved = true;
|
| - Invoker.current.removeOutstandingCallback();
|
| + var tests = declare(() {
|
| + tearDown(() {
|
| + Invoker.current.addOutstandingCallback();
|
| + pumpEventQueue().then((_) {
|
| + outstandingCallbackRemoved = true;
|
| + Invoker.current.removeOutstandingCallback();
|
| + });
|
| });
|
| - });
|
|
|
| - _declarer.test("description", () {});
|
| + test("description", () {});
|
| + });
|
|
|
| - await _runTest(0);
|
| + await _runTest(tests.single);
|
| expect(outstandingCallbackRemoved, isTrue);
|
| });
|
|
|
| @@ -198,188 +218,227 @@ void main() {
|
| var firstTearDownRun = false;
|
| var secondTearDownRun = false;
|
| var thirdTearDownRun = false;
|
| - _declarer.tearDown(expectAsync(() async {
|
| - expect(secondTearDownRun, isTrue);
|
| - expect(thirdTearDownRun, isTrue);
|
| - firstTearDownRun = true;
|
| - }));
|
| -
|
| - _declarer.tearDown(expectAsync(() async {
|
| - expect(firstTearDownRun, isFalse);
|
| - expect(thirdTearDownRun, isTrue);
|
| - secondTearDownRun = true;
|
| - }));
|
| -
|
| - _declarer.tearDown(expectAsync(() async {
|
| - expect(firstTearDownRun, isFalse);
|
| - expect(secondTearDownRun, isFalse);
|
| - thirdTearDownRun = true;
|
| - }));
|
| -
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(firstTearDownRun, isFalse);
|
| - expect(secondTearDownRun, isFalse);
|
| - expect(thirdTearDownRun, isFalse);
|
| - }, max: 1));
|
| -
|
| - await _runTest(0);
|
| + var tests = declare(() {
|
| + tearDown(expectAsync(() async {
|
| + expect(secondTearDownRun, isTrue);
|
| + expect(thirdTearDownRun, isTrue);
|
| + firstTearDownRun = true;
|
| + }));
|
| +
|
| + tearDown(expectAsync(() async {
|
| + expect(firstTearDownRun, isFalse);
|
| + expect(thirdTearDownRun, isTrue);
|
| + secondTearDownRun = true;
|
| + }));
|
| +
|
| + tearDown(expectAsync(() async {
|
| + expect(firstTearDownRun, isFalse);
|
| + expect(secondTearDownRun, isFalse);
|
| + thirdTearDownRun = true;
|
| + }));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(firstTearDownRun, isFalse);
|
| + expect(secondTearDownRun, isFalse);
|
| + expect(thirdTearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
| +
|
| + await _runTest(tests.single);
|
| });
|
|
|
| test("runs further tearDowns in a group even if one fails", () async {
|
| - _declarer.tearDown(expectAsync(() {}));
|
| + var tests = declare(() {
|
| + tearDown(expectAsync(() {}));
|
|
|
| - _declarer.tearDown(() async {
|
| - throw 'error';
|
| - });
|
| + tearDown(() async {
|
| + throw 'error';
|
| + });
|
|
|
| - _declarer.test("description", expectAsync(() {}));
|
| + test("description", expectAsync(() {}));
|
| + });
|
|
|
| - await _runTest(0, shouldFail: true);
|
| + await _runTest(tests.single, shouldFail: true);
|
| });
|
| });
|
|
|
| group("in a group,", () {
|
| test("tests inherit the group's description", () {
|
| - _declarer.group("group", () {
|
| - _declarer.test("description", () {});
|
| + var entries = declare(() {
|
| + group("group", () {
|
| + test("description", () {});
|
| + });
|
| });
|
|
|
| - expect(_declarer.tests, hasLength(1));
|
| - expect(_declarer.tests.single.name, "group description");
|
| + expect(entries, hasLength(1));
|
| + expect(entries.single, new isInstanceOf<Group>());
|
| + expect(entries.single.name, equals("group"));
|
| + expect(entries.single.entries, hasLength(1));
|
| + expect(entries.single.entries.single, new isInstanceOf<Test>());
|
| + expect(entries.single.entries.single.name, "group description");
|
| });
|
|
|
| test("a test's timeout factor is applied to the group's", () {
|
| - _declarer.group("group", () {
|
| - _declarer.test("test", () {},
|
| - timeout: new Timeout.factor(3));
|
| - }, timeout: new Timeout.factor(2));
|
| + var entries = declare(() {
|
| + group("group", () {
|
| + test("test", () {},
|
| + timeout: new Timeout.factor(3));
|
| + }, timeout: new Timeout.factor(2));
|
| + });
|
|
|
| - expect(_declarer.tests, hasLength(1));
|
| - expect(_declarer.tests.single.metadata.timeout.scaleFactor, equals(6));
|
| + expect(entries, hasLength(1));
|
| + expect(entries.single, new isInstanceOf<Group>());
|
| + expect(entries.single.metadata.timeout.scaleFactor, equals(2));
|
| + expect(entries.single.entries, hasLength(1));
|
| + expect(entries.single.entries.single, new isInstanceOf<Test>());
|
| + expect(entries.single.entries.single.metadata.timeout.scaleFactor,
|
| + equals(6));
|
| });
|
|
|
| test("a test's timeout factor is applied to the group's duration", () {
|
| - _declarer.group("group", () {
|
| - _declarer.test("test", () {},
|
| - timeout: new Timeout.factor(2));
|
| - }, timeout: new Timeout(new Duration(seconds: 10)));
|
| + var entries = declare(() {
|
| + group("group", () {
|
| + test("test", () {},
|
| + timeout: new Timeout.factor(2));
|
| + }, timeout: new Timeout(new Duration(seconds: 10)));
|
| + });
|
|
|
| - expect(_declarer.tests, hasLength(1));
|
| - expect(_declarer.tests.single.metadata.timeout.duration,
|
| + expect(entries, hasLength(1));
|
| + expect(entries.single, new isInstanceOf<Group>());
|
| + expect(entries.single.metadata.timeout.duration,
|
| + equals(new Duration(seconds: 10)));
|
| + expect(entries.single.entries, hasLength(1));
|
| + expect(entries.single.entries.single, new isInstanceOf<Test>());
|
| + expect(entries.single.entries.single.metadata.timeout.duration,
|
| equals(new Duration(seconds: 20)));
|
| });
|
|
|
| test("a test's timeout duration is applied over the group's", () {
|
| - _declarer.group("group", () {
|
| - _declarer.test("test", () {},
|
| - timeout: new Timeout(new Duration(seconds: 15)));
|
| - }, timeout: new Timeout(new Duration(seconds: 10)));
|
| + var entries = declare(() {
|
| + group("group", () {
|
| + test("test", () {},
|
| + timeout: new Timeout(new Duration(seconds: 15)));
|
| + }, timeout: new Timeout(new Duration(seconds: 10)));
|
| + });
|
|
|
| - expect(_declarer.tests, hasLength(1));
|
| - expect(_declarer.tests.single.metadata.timeout.duration,
|
| + expect(entries, hasLength(1));
|
| + expect(entries.single, new isInstanceOf<Group>());
|
| + expect(entries.single.metadata.timeout.duration,
|
| + equals(new Duration(seconds: 10)));
|
| + expect(entries.single.entries, hasLength(1));
|
| + expect(entries.single.entries.single, new isInstanceOf<Test>());
|
| + expect(entries.single.entries.single.metadata.timeout.duration,
|
| equals(new Duration(seconds: 15)));
|
| });
|
|
|
| group(".setUp()", () {
|
| test("is scoped to the group", () async {
|
| var setUpRun = false;
|
| - _declarer.group("group", () {
|
| - _declarer.setUp(() => setUpRun = true);
|
| + var entries = declare(() {
|
| + group("group", () {
|
| + setUp(() => setUpRun = true);
|
| +
|
| + test("description 1", expectAsync(() {
|
| + expect(setUpRun, isTrue);
|
| + setUpRun = false;
|
| + }, max: 1));
|
| + });
|
|
|
| - _declarer.test("description 1", expectAsync(() {
|
| - expect(setUpRun, isTrue);
|
| + test("description 2", expectAsync(() {
|
| + expect(setUpRun, isFalse);
|
| setUpRun = false;
|
| }, max: 1));
|
| });
|
|
|
| - _declarer.test("description 2", expectAsync(() {
|
| - expect(setUpRun, isFalse);
|
| - setUpRun = false;
|
| - }, max: 1));
|
| -
|
| - await _runTest(0);
|
| - await _runTest(1);
|
| + await _runTest(entries[0].entries.single);
|
| + await _runTest(entries[1]);
|
| });
|
|
|
| test("runs from the outside in", () {
|
| var outerSetUpRun = false;
|
| var middleSetUpRun = false;
|
| var innerSetUpRun = false;
|
| - _declarer.setUp(expectAsync(() {
|
| - expect(middleSetUpRun, isFalse);
|
| - expect(innerSetUpRun, isFalse);
|
| - outerSetUpRun = true;
|
| - }, max: 1));
|
| -
|
| - _declarer.group("middle", () {
|
| - _declarer.setUp(expectAsync(() {
|
| - expect(outerSetUpRun, isTrue);
|
| + var entries = declare(() {
|
| + setUp(expectAsync(() {
|
| + expect(middleSetUpRun, isFalse);
|
| expect(innerSetUpRun, isFalse);
|
| - middleSetUpRun = true;
|
| + outerSetUpRun = true;
|
| }, max: 1));
|
|
|
| - _declarer.group("inner", () {
|
| - _declarer.setUp(expectAsync(() {
|
| + group("middle", () {
|
| + setUp(expectAsync(() {
|
| expect(outerSetUpRun, isTrue);
|
| - expect(middleSetUpRun, isTrue);
|
| - innerSetUpRun = true;
|
| + expect(innerSetUpRun, isFalse);
|
| + middleSetUpRun = true;
|
| }, max: 1));
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(outerSetUpRun, isTrue);
|
| - expect(middleSetUpRun, isTrue);
|
| - expect(innerSetUpRun, isTrue);
|
| - }, max: 1));
|
| + group("inner", () {
|
| + setUp(expectAsync(() {
|
| + expect(outerSetUpRun, isTrue);
|
| + expect(middleSetUpRun, isTrue);
|
| + innerSetUpRun = true;
|
| + }, max: 1));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(outerSetUpRun, isTrue);
|
| + expect(middleSetUpRun, isTrue);
|
| + expect(innerSetUpRun, isTrue);
|
| + }, max: 1));
|
| + });
|
| });
|
| });
|
|
|
| - return _runTest(0);
|
| + return _runTest(entries.single.entries.single.entries.single);
|
| });
|
|
|
| test("handles Futures when chained", () {
|
| var outerSetUpRun = false;
|
| var innerSetUpRun = false;
|
| - _declarer.setUp(expectAsync(() {
|
| - expect(innerSetUpRun, isFalse);
|
| - return new Future(() => outerSetUpRun = true);
|
| - }, max: 1));
|
| -
|
| - _declarer.group("inner", () {
|
| - _declarer.setUp(expectAsync(() {
|
| - expect(outerSetUpRun, isTrue);
|
| - return new Future(() => innerSetUpRun = true);
|
| + var entries = declare(() {
|
| + setUp(expectAsync(() {
|
| + expect(innerSetUpRun, isFalse);
|
| + return new Future(() => outerSetUpRun = true);
|
| }, max: 1));
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(outerSetUpRun, isTrue);
|
| - expect(innerSetUpRun, isTrue);
|
| - }, max: 1));
|
| + group("inner", () {
|
| + setUp(expectAsync(() {
|
| + expect(outerSetUpRun, isTrue);
|
| + return new Future(() => innerSetUpRun = true);
|
| + }, max: 1));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(outerSetUpRun, isTrue);
|
| + expect(innerSetUpRun, isTrue);
|
| + }, max: 1));
|
| + });
|
| });
|
|
|
| - return _runTest(0);
|
| + return _runTest(entries.single.entries.single);
|
| });
|
| });
|
|
|
| group(".tearDown()", () {
|
| test("is scoped to the group", () async {
|
| var tearDownRun;
|
| - _declarer.setUp(() => tearDownRun = false);
|
| + var entries = declare(() {
|
| + setUp(() => tearDownRun = false);
|
| +
|
| + group("group", () {
|
| + tearDown(() => tearDownRun = true);
|
|
|
| - _declarer.group("group", () {
|
| - _declarer.tearDown(() => tearDownRun = true);
|
| + test("description 1", expectAsync(() {
|
| + expect(tearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
|
|
| - _declarer.test("description 1", expectAsync(() {
|
| + test("description 2", expectAsync(() {
|
| expect(tearDownRun, isFalse);
|
| }, max: 1));
|
| });
|
|
|
| - _declarer.test("description 2", expectAsync(() {
|
| - expect(tearDownRun, isFalse);
|
| - }, max: 1));
|
| -
|
| - await _runTest(0);
|
| + await _runTest(entries[0].entries.single);
|
| expect(tearDownRun, isTrue);
|
| - await _runTest(1);
|
| + await _runTest(entries[1]);
|
| expect(tearDownRun, isFalse);
|
| });
|
|
|
| @@ -387,35 +446,37 @@ void main() {
|
| var innerTearDownRun = false;
|
| var middleTearDownRun = false;
|
| var outerTearDownRun = false;
|
| - _declarer.tearDown(expectAsync(() {
|
| - expect(innerTearDownRun, isTrue);
|
| - expect(middleTearDownRun, isTrue);
|
| - outerTearDownRun = true;
|
| - }, max: 1));
|
| -
|
| - _declarer.group("middle", () {
|
| - _declarer.tearDown(expectAsync(() {
|
| + var entries = declare(() {
|
| + tearDown(expectAsync(() {
|
| expect(innerTearDownRun, isTrue);
|
| - expect(outerTearDownRun, isFalse);
|
| - middleTearDownRun = true;
|
| + expect(middleTearDownRun, isTrue);
|
| + outerTearDownRun = true;
|
| }, max: 1));
|
|
|
| - _declarer.group("inner", () {
|
| - _declarer.tearDown(expectAsync(() {
|
| + group("middle", () {
|
| + tearDown(expectAsync(() {
|
| + expect(innerTearDownRun, isTrue);
|
| expect(outerTearDownRun, isFalse);
|
| - expect(middleTearDownRun, isFalse);
|
| - innerTearDownRun = true;
|
| + middleTearDownRun = true;
|
| }, max: 1));
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(outerTearDownRun, isFalse);
|
| - expect(middleTearDownRun, isFalse);
|
| - expect(innerTearDownRun, isFalse);
|
| - }, max: 1));
|
| + group("inner", () {
|
| + tearDown(expectAsync(() {
|
| + expect(outerTearDownRun, isFalse);
|
| + expect(middleTearDownRun, isFalse);
|
| + innerTearDownRun = true;
|
| + }, max: 1));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(outerTearDownRun, isFalse);
|
| + expect(middleTearDownRun, isFalse);
|
| + expect(innerTearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
| });
|
| });
|
|
|
| - await _runTest(0);
|
| + await _runTest(entries.single.entries.single.entries.single);
|
| expect(innerTearDownRun, isTrue);
|
| expect(middleTearDownRun, isTrue);
|
| expect(outerTearDownRun, isTrue);
|
| @@ -424,57 +485,61 @@ void main() {
|
| test("handles Futures when chained", () async {
|
| var outerTearDownRun = false;
|
| var innerTearDownRun = false;
|
| - _declarer.tearDown(expectAsync(() {
|
| - expect(innerTearDownRun, isTrue);
|
| - return new Future(() => outerTearDownRun = true);
|
| - }, max: 1));
|
| -
|
| - _declarer.group("inner", () {
|
| - _declarer.tearDown(expectAsync(() {
|
| - expect(outerTearDownRun, isFalse);
|
| - return new Future(() => innerTearDownRun = true);
|
| + var entries = declare(() {
|
| + tearDown(expectAsync(() {
|
| + expect(innerTearDownRun, isTrue);
|
| + return new Future(() => outerTearDownRun = true);
|
| }, max: 1));
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(outerTearDownRun, isFalse);
|
| - expect(innerTearDownRun, isFalse);
|
| - }, max: 1));
|
| + group("inner", () {
|
| + tearDown(expectAsync(() {
|
| + expect(outerTearDownRun, isFalse);
|
| + return new Future(() => innerTearDownRun = true);
|
| + }, max: 1));
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(outerTearDownRun, isFalse);
|
| + expect(innerTearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
| });
|
|
|
| - await _runTest(0);
|
| + await _runTest(entries.single.entries.single);
|
| expect(innerTearDownRun, isTrue);
|
| expect(outerTearDownRun, isTrue);
|
| });
|
|
|
| test("runs outer callbacks even when inner ones fail", () async {
|
| var outerTearDownRun = false;
|
| - _declarer.tearDown(() {
|
| - return new Future(() => outerTearDownRun = true);
|
| - });
|
| -
|
| - _declarer.group("inner", () {
|
| - _declarer.tearDown(() {
|
| - throw 'inner error';
|
| + var entries = declare(() {
|
| + tearDown(() {
|
| + return new Future(() => outerTearDownRun = true);
|
| });
|
|
|
| - _declarer.test("description", expectAsync(() {
|
| - expect(outerTearDownRun, isFalse);
|
| - }, max: 1));
|
| + group("inner", () {
|
| + tearDown(() {
|
| + throw 'inner error';
|
| + });
|
| +
|
| + test("description", expectAsync(() {
|
| + expect(outerTearDownRun, isFalse);
|
| + }, max: 1));
|
| + });
|
| });
|
|
|
| - await _runTest(0, shouldFail: true);
|
| + await _runTest(entries.single.entries.single, shouldFail: true);
|
| expect(outerTearDownRun, isTrue);
|
| });
|
| });
|
| });
|
| }
|
|
|
| -/// Runs the test at [index] defined on [_declarer].
|
| +/// Runs [test].
|
| ///
|
| /// This automatically sets up an `onError` listener to ensure that the test
|
| /// doesn't throw any invisible exceptions.
|
| -Future _runTest(int index, {bool shouldFail: false}) {
|
| - var liveTest = _declarer.tests[index].load(_suite);
|
| +Future _runTest(Test test, {bool shouldFail: false}) {
|
| + var liveTest = test.load(_suite);
|
|
|
| liveTest.onError.listen(shouldFail
|
| ? expectAsync((_) {})
|
|
|