Chromium Code Reviews| Index: lib/unittest/testcase.dart |
| diff --git a/lib/unittest/testcase.dart b/lib/unittest/testcase.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..23eef81002bd602f9bcfb54c8e848b38c4f537f2 |
| --- /dev/null |
| +++ b/lib/unittest/testcase.dart |
| @@ -0,0 +1,60 @@ |
| +// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +/** |
| + * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] |
| + * and assumes unittest defines the type [TestFunction]. |
| + */ |
| + |
| +/** Summarizes information about a single test case. */ |
| +class TestCase { |
|
Siggi Cherem (dart-lang)
2012/04/12 01:13:53
ditto (unchanged, moved to its own file)
|
| + /** Identifier for this test. */ |
| + final id; |
|
Bob Nystrom
2012/04/12 16:45:49
Type?
Siggi Cherem (dart-lang)
2012/04/12 17:36:28
Done.
|
| + |
| + /** A description of what the test is specifying. */ |
| + final String description; |
| + |
| + /** The body of the test case. */ |
| + final TestFunction test; |
| + |
| + /** Total number of callbacks to wait for before the test completes. */ |
| + int callbacks; |
| + |
| + /** Error or failure message. */ |
| + String message = ''; |
| + |
| + /** |
| + * One of [_PASS], [_FAIL], or [_ERROR] or [null] if the test hasn't run yet. |
| + */ |
| + String result; |
| + |
| + /** Stack trace associated with this test, or null if it succeeded. */ |
| + String stackTrace; |
| + |
| + Date startTime; |
| + |
| + Duration runningTime; |
| + |
| + TestCase(this.id, this.description, this.test, this.callbacks); |
| + |
| + bool get isComplete() => result != null; |
| + |
| + void pass() { |
| + result = _PASS; |
| + } |
| + |
| + void fail(String message_, String stackTrace_) { |
|
Bob Nystrom
2012/04/12 16:45:49
Are the trailing underscores needed here?
Siggi Cherem (dart-lang)
2012/04/12 17:36:28
Done.
|
| + result = _FAIL; |
| + this.message = message_; |
|
Bob Nystrom
2012/04/12 16:45:49
If they are, then get rid of "this." here.
Siggi Cherem (dart-lang)
2012/04/12 17:36:28
Done.
|
| + this.stackTrace = stackTrace_; |
| + } |
| + |
| + void error(String message_, String stackTrace_) { |
| + result = _ERROR; |
| + this.message = message_; |
| + this.stackTrace = stackTrace_; |
| + } |
| +} |
| + |
| + |