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

Unified Diff: pkg/unittest/lib/src/test_case.dart

Issue 13814017: Don't try to measure the running time if the test hasn't started yet. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add comment. Created 7 years, 8 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/unittest/lib/src/test_case.dart
diff --git a/pkg/unittest/lib/src/test_case.dart b/pkg/unittest/lib/src/test_case.dart
index f8eb233530ddb98ad409d0c9db82ed12c344c48c..23d04dee256a733c0e60f2f39d06e10a7ccbf8a4 100644
--- a/pkg/unittest/lib/src/test_case.dart
+++ b/pkg/unittest/lib/src/test_case.dart
@@ -158,7 +158,13 @@ class TestCase {
[String messageText = '',
String stack = '']) {
if (runningTime == null) {
- _runningTime = new DateTime.now().difference(startTime);
+ // The startTime can be `null` if an error happened during setup. In this
+ // case we simply report a running time of 0.
+ if (startTime != null) {
+ _runningTime = new DateTime.now().difference(startTime);
+ } else {
+ _runningTime = const Duration(seconds: 0);
+ }
}
_setResult(testResult, messageText, stack);
if (!_doneTeardown) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698