TestSuite.js revision 33d85edf47749fa345d7b636b9b4b9d0d0386f44
0N/A
381N/A
0N/A/**
0N/A * A test suite that can contain a collection of TestCase and TestSuite objects.
0N/A * @param {String||Object} data The name of the test suite or an object containing
0N/A * a name property as well as setUp and tearDown methods.
0N/A * @namespace YUITest
0N/A * @class TestSuite
0N/A * @constructor
0N/A */
0N/AYUITest.TestSuite = function (data) {
0N/A
0N/A /**
0N/A * The name of the test suite.
0N/A * @type String
0N/A * @property name
0N/A */
0N/A this.name = "";
0N/A
0N/A /**
0N/A * Array of test suites and test cases.
0N/A * @type Array
0N/A * @property items
0N/A * @private
0N/A */
0N/A this.items = [];
0N/A
0N/A //initialize the properties
0N/A if (typeof data == "string"){
0N/A this.name = data;
0N/A } else if (data instanceof Object){
0N/A for (var prop in data){
0N/A if (data.hasOwnProperty(prop)){
0N/A this[prop] = data[prop];
0N/A }
16N/A }
0N/A }
0N/A
0N/A //double-check name
0N/A if (this.name === ""){
0N/A this.name = "testSuite" + (+new Date());
0N/A }
0N/A
0N/A};
0N/A
0N/AYUITest.TestSuite.prototype = {
0N/A
0N/A //restore constructor
0N/A constructor: YUITest.TestSuite,
0N/A
0N/A /**
1365N/A * Adds a test suite or test case to the test suite.
0N/A * @param {YUITest.TestSuite||YUITest.TestCase} testObject The test suite or test case to add.
0N/A * @return {Void}
0N/A * @method add
0N/A */
0N/A add : function (testObject) {
0N/A if (testObject instanceof YUITest.TestSuite || testObject instanceof YUITest.TestCase) {
0N/A this.items.push(testObject);
0N/A }
0N/A return this;
0N/A },
0N/A
0N/A //-------------------------------------------------------------------------
0N/A // Stub Methods
0N/A //-------------------------------------------------------------------------
0N/A
0N/A /**
0N/A * Function to run before each test is executed.
0N/A * @return {Void}
0N/A * @method setUp
0N/A */
0N/A setUp : function () {
0N/A },
0N/A
0N/A /**
0N/A * Function to run after each test is executed.
0N/A * @return {Void}
0N/A * @method tearDown
0N/A */
0N/A tearDown: function () {
0N/A }
0N/A
0N/A};
0N/A