| Index: lib/unittest/test_case.dart
|
| ===================================================================
|
| --- lib/unittest/test_case.dart (revision 8913)
|
| +++ lib/unittest/test_case.dart (working copy)
|
| @@ -7,7 +7,6 @@
|
| * and assumes unittest defines the type [TestFunction].
|
| */
|
|
|
| -
|
| /** Summarizes information about a single test case. */
|
| class TestCase {
|
| /** Identifier for this test. */
|
| @@ -16,6 +15,12 @@
|
| /** A description of what the test is specifying. */
|
| final String description;
|
|
|
| + /** The setup function to call before the test, if any. */
|
| + final _setup;
|
| +
|
| + /** The teardown function to call after the test, if any. */
|
| + final _teardown;
|
| +
|
| /** The body of the test case. */
|
| final TestFunction test;
|
|
|
| @@ -35,16 +40,31 @@
|
|
|
| /** The group (or groups) under which this test is running. */
|
| final String currentGroup;
|
| -
|
| +
|
| Date startTime;
|
|
|
| Duration runningTime;
|
|
|
| TestCase(this.id, this.description, this.test, this.callbacks)
|
| - : currentGroup = _currentGroup;
|
| + : currentGroup = _currentGroup,
|
| + _setup = _testSetup,
|
| + _teardown = _testTeardown;
|
|
|
| bool get isComplete() => result != null;
|
|
|
| + void run() {
|
| + if (_setup != null) {
|
| + _setup();
|
| + }
|
| + try {
|
| + test();
|
| + } finally {
|
| + if (_teardown != null) {
|
| + _teardown();
|
| + }
|
| + }
|
| + }
|
| +
|
| void pass() {
|
| result = _PASS;
|
| }
|
|
|