/GHUnitIOS.framework/Versions/A/Headers/GHTestGroup.h

http://github.com/zwaldowski/BlocksKit · C++ Header · 176 lines · 37 code · 26 blank · 113 comment · 0 complexity · 6cec209a5937dcbab4746cb6b67fa6b5 MD5 · raw file

  1. //
  2. // GHTestGroup.h
  3. //
  4. // Created by Gabriel Handford on 1/16/09.
  5. // Copyright 2009. All rights reserved.
  6. //
  7. // Permission is hereby granted, free of charge, to any person
  8. // obtaining a copy of this software and associated documentation
  9. // files (the "Software"), to deal in the Software without
  10. // restriction, including without limitation the rights to use,
  11. // copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. // copies of the Software, and to permit persons to whom the
  13. // Software is furnished to do so, subject to the following
  14. // conditions:
  15. //
  16. // The above copyright notice and this permission notice shall be
  17. // included in all copies or substantial portions of the Software.
  18. //
  19. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
  21. // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  25. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  26. // OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. //! @cond DEV
  29. #import "GHTest.h"
  30. #import "GHTestCase.h"
  31. /*!
  32. @brief Interface for a group of tests.
  33. This group conforms to the GHTest protocol as well (see Composite pattern).
  34. */
  35. @protocol GHTestGroup <GHTest>
  36. - (NSString *)name;
  37. - (id<GHTestGroup>)parent;
  38. - (NSArray *)children;
  39. @end
  40. /*!
  41. @brief A collection of tests (or test groups).
  42. A test group is a collection of id<GHTest>, that may represent a set of test case methods.
  43. For example, if you had the following GHTestCase.
  44. @code
  45. @interface FooTest : GHTestCase {}
  46. - (void)testFoo;
  47. - (void)testBar;
  48. @end
  49. @endcode
  50. The GHTestGroup would consist of and array of GHTest, [FooTest#testFoo and FooTest#testBar],
  51. each test being a target and selector pair.
  52. A test group may also consist of a group of groups (since GHTestGroup conforms to GHTest),
  53. and this might represent a GHTestSuite.
  54. */
  55. @interface GHTestGroup : NSObject <GHTestDelegate, GHTestGroup> {
  56. NSObject<GHTestDelegate> *delegate_; // weak
  57. id<GHTestGroup> parent_; // weak
  58. NSMutableArray */*of id<GHTest>*/children_;
  59. NSString *name_; // The name of the test group (usually the class name of the test case
  60. NSTimeInterval interval_; // Total time of child tests
  61. GHTestStatus status_; // Current status of the group (current status of running or completed child tests)
  62. GHTestStats stats_; // Current stats for the group (aggregate of child test stats)
  63. BOOL didSetUpClass_;
  64. GHTestOptions options_;
  65. // Set if test is created from initWithTestCase:delegate:
  66. // Allows use to perform setUpClass and tearDownClass (once per test case run)
  67. id testCase_;
  68. NSException *exception_; // If exception happens in group setUpClass/tearDownClass
  69. }
  70. @property (readonly, nonatomic) NSArray */*of id<GHTest>*/children;
  71. @property (assign, nonatomic) id<GHTestGroup> parent;
  72. @property (readonly, nonatomic) id testCase;
  73. @property (assign, nonatomic) GHTestOptions options;
  74. /*!
  75. Create an empty test group.
  76. @param name The name of the test group
  77. @param delegate Delegate, notifies of test start and end
  78. @result New test group
  79. */
  80. - (id)initWithName:(NSString *)name delegate:(id<GHTestDelegate>)delegate;
  81. /*!
  82. Create test group from a test case.
  83. @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
  84. @param delegate Delegate, notifies of test start and end
  85. @result New test group
  86. */
  87. - (id)initWithTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate;
  88. /*!
  89. Create test group from a single test.
  90. @param testCase
  91. @param selector Test to run
  92. @param delegate
  93. */
  94. - (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id<GHTestDelegate>)delegate;
  95. /*!
  96. Create test group from a test case.
  97. @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
  98. @param delegate Delegate, notifies of test start and end
  99. @result New test group
  100. */
  101. + (GHTestGroup *)testGroupFromTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate;
  102. /*!
  103. Add a test case (or test group) to this test group.
  104. @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
  105. */
  106. - (void)addTestCase:(id)testCase;
  107. /*!
  108. Add a test group to this test group.
  109. @param testGroup Test group to add
  110. */
  111. - (void)addTestGroup:(GHTestGroup *)testGroup;
  112. /*!
  113. Add tests to this group.
  114. @param tests Tests to add
  115. */
  116. - (void)addTests:(NSArray */*of id<GHTest>*/)tests;
  117. /*!
  118. Add test to this group.
  119. @param test Test to add
  120. */
  121. - (void)addTest:(id<GHTest>)test;
  122. /*!
  123. Whether the test group should run on the main thread.
  124. Call passes to test case instance if enabled.
  125. */
  126. - (BOOL)shouldRunOnMainThread;
  127. /*!
  128. @result YES if we have any enabled chilren, NO if all children have been disabled.
  129. */
  130. - (BOOL)hasEnabledChildren;
  131. /*!
  132. Get list of failed tests.
  133. @result Failed tests
  134. */
  135. - (NSArray */*of id<GHTest>*/)failedTests;
  136. /*!
  137. Run in operation queue.
  138. Tests from the group are added and will block until they have completed.
  139. @param operationQueue If nil, then runs as is
  140. @param options Options
  141. */
  142. - (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOptions)options;
  143. @end
  144. //! @endcond