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

Side by Side Diff: pkg/scheduled_test/lib/scheduled_test.dart

Issue 12208096: Make the scheduled_test schedule keep track of multiple errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 7 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // TODO(nweiz): Keep track of and display multiple errors so there's more
6 // visibility into cascading errors.
7 // TODO(nweiz): Add timeouts to scheduled tests. 5 // TODO(nweiz): Add timeouts to scheduled tests.
8 // TODO(nweiz): Add support for calling [schedule] while the schedule is already 6 // TODO(nweiz): Add support for calling [schedule] while the schedule is already
9 // running. 7 // running.
10 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub. 8 // TODO(nweiz): Port the non-Pub-specific scheduled test libraries from Pub.
11 /// A package for writing readable tests of asynchronous behavior. 9 /// A package for writing readable tests of asynchronous behavior.
12 /// 10 ///
13 /// This package works by building up a queue of asynchronous tasks called a 11 /// This package works by building up a queue of asynchronous tasks called a
14 /// "schedule", then executing those tasks in order. This allows the tests to 12 /// "schedule", then executing those tasks in order. This allows the tests to
15 /// read like synchronous, linear code, despite executing asynchronously. 13 /// read like synchronous, linear code, despite executing asynchronously.
16 /// 14 ///
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 testFn(description, () { 185 testFn(description, () {
188 var asyncDone = unittest.expectAsync0(() {}); 186 var asyncDone = unittest.expectAsync0(() {});
189 return currentSchedule.run(() { 187 return currentSchedule.run(() {
190 if (_setUpFn != null) _setUpFn(); 188 if (_setUpFn != null) _setUpFn();
191 body(); 189 body();
192 }).then((_) { 190 }).then((_) {
193 // If we got here, the test completed successfully so tell unittest so. 191 // If we got here, the test completed successfully so tell unittest so.
194 asyncDone(); 192 asyncDone();
195 }).catchError((e) { 193 }).catchError((e) {
196 if (e is ScheduleError) { 194 if (e is ScheduleError) {
197 unittest.registerException(new ExpectException(e.toString())); 195 assert(e.schedule.errors.contains(e));
196 assert(e.schedule == currentSchedule);
197 unittest.registerException(e.schedule.errorString());
198 } else if (e is AsyncError) { 198 } else if (e is AsyncError) {
199 unittest.registerException(e.error, e.stackTrace); 199 unittest.registerException(e.error, e.stackTrace);
200 } else { 200 } else {
201 unittest.registerException(e); 201 unittest.registerException(e);
202 } 202 }
203 }); 203 });
204 }); 204 });
205 } 205 }
206 206
207 /// Whether or not the tests currently being defined are in a group. This is 207 /// Whether or not the tests currently being defined are in a group. This is
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 unittest.ensureInitialized(); 283 unittest.ensureInitialized();
284 unittest.wrapAsync = (f) { 284 unittest.wrapAsync = (f) {
285 if (currentSchedule == null) { 285 if (currentSchedule == null) {
286 throw new StateError("Unexpected call to wrapAsync with no current " 286 throw new StateError("Unexpected call to wrapAsync with no current "
287 "schedule."); 287 "schedule.");
288 } 288 }
289 289
290 return currentSchedule.wrapAsync(f); 290 return currentSchedule.wrapAsync(f);
291 }; 291 };
292 } 292 }
OLDNEW
« no previous file with comments | « no previous file | pkg/scheduled_test/lib/src/schedule.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698