// Copyright 2007 The Closure Library Authors. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS-IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. /** * @fileoverview A class representing a set of test functions to be run. * * Testing code should not have dependencies outside of goog.testing so as to * reduce the chance of masking missing dependencies. * * This file does not compile correctly with --collapse_properties. Use * --property_renaming=ALL_UNQUOTED instead. * */ goog.provide('goog.testing.TestCase'); goog.provide('goog.testing.TestCase.Error'); goog.provide('goog.testing.TestCase.Order'); goog.provide('goog.testing.TestCase.Result'); goog.provide('goog.testing.TestCase.Test'); goog.require('goog.object'); goog.require('goog.testing.asserts'); goog.require('goog.testing.stacktrace'); /** * A class representing a JsUnit test case. A TestCase is made up of a number * of test functions which can be run. Individual test cases can override the * following functions to set up their test environment: * - runTests - completely override the test's runner * - setUpPage - called before any of the test functions are run * - tearDownPage - called after all tests are finished * - setUp - called before each of the test functions * - tearDown - called after each of the test functions * - shouldRunTests - called before a test run, all tests are skipped if it * returns false. Can be used to disable tests on browsers * where they aren't expected to pass. * * Use {@link #autoDiscoverTests} * * @param {string=} opt_name The name of the test case, defaults to * 'Untitled Test Case'. * @constructor */ goog.testing.TestCase = function(opt_name) { /** * A name for the test case. * @type {string} * @private */ this.name_ = opt_name || 'Untitled Test Case'; /** * Array of test functions that can be executed. * @type {!Array.} * @private */ this.tests_ = []; /** * Set of test names and/or indices to execute, or null if all tests should * be executed. * * Indices are included to allow automation tools to run a subset of the * tests without knowing the exact contents of the test file. * * Indices should only be used with SORTED ordering. * * Example valid values: *