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

Unified Diff: lib/unittest/future_matchers.dart

Issue 10766006: Print the stack traces for Future expectations that raise exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « lib/unittest/core_matchers.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/unittest/future_matchers.dart
diff --git a/lib/unittest/future_matchers.dart b/lib/unittest/future_matchers.dart
index 1f3a5744e456c898a87a8c76ad0cd6f668c860a3..e95e1b1ad9fdda5df4950f33542291bb83e58142 100644
--- a/lib/unittest/future_matchers.dart
+++ b/lib/unittest/future_matchers.dart
@@ -33,8 +33,15 @@ class _Completes extends BaseMatcher {
if (item is! Future) return false;
item.onComplete(expectAsync1((future) {
- expect(future.hasValue,
- reason: 'Expected future to complete successfully, but it failed');
+ var reason = 'Expected future to complete successfully, but it failed '
+ 'with ${future.exception}';
+ if (future.stackTrace != null) {
+ var stackTrace = future.stackTrace.toString();
+ stackTrace = ' ${stackTrace.replaceAll('\n', '\n ')}';
+ reason = '$reason\nStack trace:\n$stackTrace';
+ }
+
+ expect(future.hasValue, reason: reason);
if (_matcher != null) expect(future.value, _matcher);
}));
« no previous file with comments | « lib/unittest/core_matchers.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698