Dart API ReferenceunittestTestCase

TestCase Class

Summarizes information about a single test case.

Constructors

Code new TestCase(int id, String description, TestFunction test, int callbackFunctionsOutstanding) #

TestCase(this.id, this.description, this.test,
         this.callbackFunctionsOutstanding)
: currentGroup = _currentGroup,
  _setUp = _testSetup,
  _tearDown = _testTeardown;

Methods

Code void error(String messageText, String stack) #

void error(String messageText, String stack) {
  result = _ERROR;
  message = messageText;
  stackTrace = stack;
  _complete();
}

Code void fail(String messageText, String stack) #

void fail(String messageText, String stack) {
  result = _FAIL;
  message = messageText;
  stackTrace = stack;
  _complete();
}

Code bool get isComplete() #

bool get isComplete() => !enabled || result != null;

Code void pass() #

void pass() {
  result = _PASS;
  _complete();
}

Code void run() #

void run() {
  if (enabled) {
    result = stackTrace = null;
    message = '';
    _doneTeardown = false;
    if (_setUp != null) {
      _setUp();
    }
    _config.onTestStart(this);
    test();
  }
}

Code Function get setUp() #

Function get setUp() => _setUp;

Code set setUp(Function value) #

set setUp(Function value) => _setUp = value;

Code Function get tearDown() #

Function get tearDown() => _tearDown;

Code set tearDown(Function value) #

set tearDown(Function value) => _tearDown = value;

Fields

Code int callbackFunctionsOutstanding #

Remaining number of callbacks functions that must reach a 'done' state to wait for before the test completes.

int callbackFunctionsOutstanding;

Code final String currentGroup #

The group (or groups) under which this test is running.

final String currentGroup;

Code final String description #

A description of what the test is specifying.

final String description;

Code bool enabled #

bool enabled = true;

Code final int id #

Identifier for this test.

final int id;

Code String message #

Error or failure message.

String message = '';

Code String result #

One of _PASS, _FAIL, _ERROR, or null if the test hasn't run yet.

String result;

Code Duration runningTime #

Duration runningTime;

Code String stackTrace #

Stack trace associated with this test, or null if it succeeded.

String stackTrace;

Code Date startTime #

Date startTime;

Code TestFunction test #

The body of the test case.

TestFunction test;