API Docs for: 3.17.2
Show:

File: test/js/TestSuite.js

  1.  
  2.  
  3. /**
  4. * A test suite that can contain a collection of TestCase and TestSuite objects.
  5. * @param {String||Object} data The name of the test suite or an object containing
  6. * a name property as well as setUp and tearDown methods.
  7. * @namespace Test
  8. * @module test
  9. * @class TestSuite
  10. * @constructor
  11. */
  12. YUITest.TestSuite = function (data) {
  13.  
  14. /**
  15. * The name of the test suite.
  16. * @type String
  17. * @property name
  18. */
  19. this.name = "";
  20.  
  21. /**
  22. * Array of test suites and test cases.
  23. * @type Array
  24. * @property items
  25. * @private
  26. */
  27. this.items = [];
  28.  
  29. //initialize the properties
  30. if (typeof data == "string"){
  31. this.name = data;
  32. } else if (data instanceof Object){
  33. for (var prop in data){
  34. if (data.hasOwnProperty(prop)){
  35. this[prop] = data[prop];
  36. }
  37. }
  38. }
  39.  
  40. //double-check name
  41. if (this.name === "" || !this.name) {
  42. this.name = YUITest.guid("testSuite_");
  43. }
  44.  
  45. };
  46.  
  47. YUITest.TestSuite.prototype = {
  48.  
  49. //restore constructor
  50. constructor: YUITest.TestSuite,
  51.  
  52. /**
  53. * Adds a test suite or test case to the test suite.
  54. * @param {Test.TestSuite||YUITest.TestCase} testObject The test suite or test case to add.
  55. * @method add
  56. */
  57. add : function (testObject) {
  58. if (testObject instanceof YUITest.TestSuite || testObject instanceof YUITest.TestCase) {
  59. this.items.push(testObject);
  60. }
  61. return this;
  62. },
  63.  
  64. //-------------------------------------------------------------------------
  65. // Stub Methods
  66. //-------------------------------------------------------------------------
  67.  
  68. /**
  69. * Function to run before each test is executed.
  70. * @method setUp
  71. */
  72. setUp : function () {
  73. },
  74.  
  75. /**
  76. * Function to run after each test is executed.
  77. * @method tearDown
  78. */
  79. tearDown: function () {
  80. }
  81.  
  82. };
  83.