| 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 d4802ea8ce1b6d36ac72afa8621c8471e3ddc095..0948e79e1979af6b3d59457e6bb52f8168ac9b7f 100644
|
| --- a/pkg/unittest/lib/src/test_case.dart
|
| +++ b/pkg/unittest/lib/src/test_case.dart
|
| @@ -4,51 +4,45 @@
|
|
|
| part of unittest;
|
|
|
| -/**
|
| - * Represents the state for an individual unit test.
|
| - *
|
| - * Create by calling [test] or [solo_test].
|
| - */
|
| +/// Represents the state for an individual unit test.
|
| +///
|
| +/// Create by calling [test] or [solo_test].
|
| class TestCase {
|
| - /** Identifier for this test. */
|
| + /// Identifier for this test.
|
| final int id;
|
|
|
| - /** A description of what the test is specifying. */
|
| + /// A description of what the test is specifying.
|
| final String description;
|
|
|
| - /** The setup function to call before the test, if any. */
|
| + /// The setup function to call before the test, if any.
|
| final Function _setUp;
|
|
|
| - /** The teardown function to call after the test, if any. */
|
| + /// The teardown function to call after the test, if any.
|
| final Function _tearDown;
|
|
|
| - /** The body of the test case. */
|
| + /// The body of the test case.
|
| final TestFunction _testFunction;
|
|
|
| - /**
|
| - * Remaining number of callbacks functions that must reach a 'done' state
|
| - * to wait for before the test completes.
|
| - */
|
| + /// Remaining number of callbacks functions that must reach a 'done' state
|
| + /// to wait for before the test completes.
|
| int _callbackFunctionsOutstanding = 0;
|
|
|
| String _message = '';
|
| - /** Error or failure message. */
|
| + /// Error or failure message.
|
| String get message => _message;
|
|
|
| String _result;
|
| - /**
|
| - * One of [PASS], [FAIL], [ERROR], or [:null:] if the test hasn't run yet.
|
| - */
|
| + /// One of [PASS], [FAIL], [ERROR], or [:null:] if the test hasn't run yet.
|
| String get result => _result;
|
|
|
| - /** Returns whether this test case passed. */
|
| + /// Returns whether this test case passed.
|
| bool get passed => _result == PASS;
|
|
|
| StackTrace _stackTrace;
|
| - /** Stack trace associated with this test, or [:null:] if it succeeded. */
|
| + /// Stack trace associated with this test, or [:null:] if it succeeded.
|
| StackTrace get stackTrace => _stackTrace;
|
|
|
| - /** The group (or groups) under which this test is running. */
|
| + /// The group (or groups) under which this test is running.
|
| final String currentGroup;
|
|
|
| DateTime _startTime;
|
| @@ -85,12 +79,10 @@ class TestCase {
|
| }
|
| };
|
|
|
| - /**
|
| - * Perform any associated [_setUp] function and run the test. Returns
|
| - * a [Future] that can be used to schedule the next test. If the test runs
|
| - * to completion synchronously, or is disabled, null is returned, to
|
| - * tell unittest to schedule the next test immediately.
|
| - */
|
| + /// Perform any associated [_setUp] function and run the test. Returns
|
| + /// a [Future] that can be used to schedule the next test. If the test runs
|
| + /// to completion synchronously, or is disabled, null is returned, to
|
| + /// tell unittest to schedule the next test immediately.
|
| Future _run() {
|
| if (!enabled) return new Future.value();
|
|
|
| @@ -100,32 +92,28 @@ class TestCase {
|
| // Avoid calling [new Future] to avoid issue 11911.
|
| return new Future.value().then((_) {
|
| if (_setUp != null) return _setUp();
|
| - }).catchError(_errorHandler('Setup'))
|
| - .then((_) {
|
| - // Skip the test if setup failed.
|
| - if (result != null) return new Future.value();
|
| - _config.onTestStart(this);
|
| - _startTime = new DateTime.now();
|
| - _runningTime = null;
|
| - ++_callbackFunctionsOutstanding;
|
| - return _testFunction();
|
| - })
|
| - .catchError(_errorHandler('Test'))
|
| - .then((_) {
|
| - _markCallbackComplete();
|
| - if (result == null) {
|
| - // Outstanding callbacks exist; we need to return a Future.
|
| - _testComplete = new Completer();
|
| - return _testComplete.future.whenComplete(() {
|
| - if (_tearDown != null) {
|
| - return _tearDown();
|
| - }
|
| - }).catchError(_errorHandler('Teardown'));
|
| - } else if (_tearDown != null) {
|
| + }).catchError(_errorHandler('Setup')).then((_) {
|
| + // Skip the test if setup failed.
|
| + if (result != null) return new Future.value();
|
| + _config.onTestStart(this);
|
| + _startTime = new DateTime.now();
|
| + _runningTime = null;
|
| + ++_callbackFunctionsOutstanding;
|
| + return _testFunction();
|
| + }).catchError(_errorHandler('Test')).then((_) {
|
| + _markCallbackComplete();
|
| + if (result == null) {
|
| + // Outstanding callbacks exist; we need to return a Future.
|
| + _testComplete = new Completer();
|
| + return _testComplete.future.whenComplete(() {
|
| + if (_tearDown != null) {
|
| return _tearDown();
|
| }
|
| - })
|
| - .catchError(_errorHandler('Teardown'));
|
| + }).catchError(_errorHandler('Teardown'));
|
| + } else if (_tearDown != null) {
|
| + return _tearDown();
|
| + }
|
| + }).catchError(_errorHandler('Teardown'));
|
| }
|
|
|
| // Set the results, notify the config, and return true if this
|
|
|