mongo-dart / third_party / unittest / test_case.dart

vadimtsushko 6d0faa6 





























































// 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 {
  /** Identifier for this test. */
  final int id;

  /** 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;

  /** 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;

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

  void pass() {
    result = _PASS;
  }

  void fail(String message, String stackTrace) {
    result = _FAIL;
    this.message = message;
    this.stackTrace = stackTrace;
  }

  void error(String message, String stackTrace) {
    result = _ERROR;
    this.message = message;
    this.stackTrace = stackTrace;
  }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.