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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:test/src/backend/declarer.dart'; | 7 import 'package:test/src/backend/declarer.dart'; |
8 import 'package:test/src/backend/suite.dart'; | 8 import 'package:test/src/backend/suite.dart'; |
| 9 import 'package:test/src/frontend/timeout.dart'; |
9 import 'package:test/test.dart'; | 10 import 'package:test/test.dart'; |
10 | 11 |
11 Declarer _declarer; | 12 Declarer _declarer; |
12 Suite _suite; | 13 Suite _suite; |
13 | 14 |
14 void main() { | 15 void main() { |
15 setUp(() { | 16 setUp(() { |
16 _declarer = new Declarer(); | 17 _declarer = new Declarer(); |
17 _suite = new Suite([]); | 18 _suite = new Suite([]); |
18 }); | 19 }); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 group("in a group,", () { | 124 group("in a group,", () { |
124 test("tests inherit the group's description", () { | 125 test("tests inherit the group's description", () { |
125 _declarer.group("group", () { | 126 _declarer.group("group", () { |
126 _declarer.test("description", () {}); | 127 _declarer.test("description", () {}); |
127 }); | 128 }); |
128 | 129 |
129 expect(_declarer.tests, hasLength(1)); | 130 expect(_declarer.tests, hasLength(1)); |
130 expect(_declarer.tests.single.name, "group description"); | 131 expect(_declarer.tests.single.name, "group description"); |
131 }); | 132 }); |
132 | 133 |
| 134 test("a test's timeout factor is applied to the group's", () { |
| 135 _declarer.group("group", () { |
| 136 _declarer.test("test", () {}, |
| 137 timeout: new Timeout.factor(3)); |
| 138 }, timeout: new Timeout.factor(2)); |
| 139 |
| 140 expect(_declarer.tests, hasLength(1)); |
| 141 expect(_declarer.tests.single.metadata.timeout.scaleFactor, equals(6)); |
| 142 }); |
| 143 |
| 144 test("a test's timeout factor is applied to the group's duration", () { |
| 145 _declarer.group("group", () { |
| 146 _declarer.test("test", () {}, |
| 147 timeout: new Timeout.factor(2)); |
| 148 }, timeout: new Timeout(new Duration(seconds: 10))); |
| 149 |
| 150 expect(_declarer.tests, hasLength(1)); |
| 151 expect(_declarer.tests.single.metadata.timeout.duration, |
| 152 equals(new Duration(seconds: 20))); |
| 153 }); |
| 154 |
| 155 test("a test's timeout duration is applied over the group's", () { |
| 156 _declarer.group("group", () { |
| 157 _declarer.test("test", () {}, |
| 158 timeout: new Timeout(new Duration(seconds: 15))); |
| 159 }, timeout: new Timeout(new Duration(seconds: 10))); |
| 160 |
| 161 expect(_declarer.tests, hasLength(1)); |
| 162 expect(_declarer.tests.single.metadata.timeout.duration, |
| 163 equals(new Duration(seconds: 15))); |
| 164 }); |
| 165 |
133 group(".setUp()", () { | 166 group(".setUp()", () { |
134 test("is scoped to the group", () { | 167 test("is scoped to the group", () { |
135 var setUpRun = false; | 168 var setUpRun = false; |
136 _declarer.group("group", () { | 169 _declarer.group("group", () { |
137 _declarer.setUp(() => setUpRun = true); | 170 _declarer.setUp(() => setUpRun = true); |
138 | 171 |
139 _declarer.test("description 1", expectAsync(() { | 172 _declarer.test("description 1", expectAsync(() { |
140 expect(setUpRun, isTrue); | 173 expect(setUpRun, isTrue); |
141 setUpRun = false; | 174 setUpRun = false; |
142 }, max: 1)); | 175 }, max: 1)); |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 /// Runs the test at [index] defined on [_declarer]. | 350 /// Runs the test at [index] defined on [_declarer]. |
318 /// | 351 /// |
319 /// This automatically sets up an `onError` listener to ensure that the test | 352 /// This automatically sets up an `onError` listener to ensure that the test |
320 /// doesn't throw any invisible exceptions. | 353 /// doesn't throw any invisible exceptions. |
321 Future _runTest(int index) { | 354 Future _runTest(int index) { |
322 var liveTest = _declarer.tests[index].load(_suite); | 355 var liveTest = _declarer.tests[index].load(_suite); |
323 liveTest.onError.listen(expectAsync((_) {}, | 356 liveTest.onError.listen(expectAsync((_) {}, |
324 count: 0, reason: "No errors expected for test #$index.")); | 357 count: 0, reason: "No errors expected for test #$index.")); |
325 return liveTest.run(); | 358 return liveTest.run(); |
326 } | 359 } |
OLD | NEW |