Version 3.18.1
Show:

File: test/js/TestSuite.js

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