PageRenderTime 54ms CodeModel.GetById 44ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 29//! @cond DEV
 30
 31#import "GHTest.h"
 32#import "GHTestCase.h"
 33
 34/*!
 35 @brief Interface for a group of tests.
 36
 37 This group conforms to the GHTest protocol as well (see Composite pattern).
 38 */
 39@protocol GHTestGroup <GHTest>
 40- (NSString *)name;
 41- (id<GHTestGroup>)parent;
 42- (NSArray *)children;
 43@end
 44
 45/*!
 46 @brief A collection of tests (or test groups).
 47
 48 A test group is a collection of id<GHTest>, that may represent a set of test case methods. 
 49 
 50 For example, if you had the following GHTestCase.
 51
 52 @code
 53 @interface FooTest : GHTestCase {}
 54 - (void)testFoo;
 55 - (void)testBar;
 56 @end
 57 @endcode
 58 
 59 The GHTestGroup would consist of and array of GHTest, [FooTest#testFoo and FooTest#testBar], 
 60 each test being a target and selector pair.
 61
 62 A test group may also consist of a group of groups (since GHTestGroup conforms to GHTest),
 63 and this might represent a GHTestSuite.
 64 */
 65@interface GHTestGroup : NSObject <GHTestDelegate, GHTestGroup> {
 66  
 67  NSObject<GHTestDelegate> *delegate_; // weak
 68  id<GHTestGroup> parent_; // weak
 69  
 70  NSMutableArray */*of id<GHTest>*/children_;
 71    
 72  NSString *name_; // The name of the test group (usually the class name of the test case
 73  NSTimeInterval interval_; // Total time of child tests
 74  GHTestStatus status_; // Current status of the group (current status of running or completed child tests)
 75  GHTestStats stats_; // Current stats for the group (aggregate of child test stats)
 76  
 77  BOOL didSetUpClass_;
 78  
 79  GHTestOptions options_;
 80  
 81  // Set if test is created from initWithTestCase:delegate:
 82  // Allows use to perform setUpClass and tearDownClass (once per test case run)
 83  id testCase_; 
 84  
 85  NSException *exception_; // If exception happens in group setUpClass/tearDownClass
 86}
 87
 88@property (readonly, nonatomic) NSArray */*of id<GHTest>*/children;
 89@property (assign, nonatomic) id<GHTestGroup> parent;
 90@property (readonly, nonatomic) id testCase;
 91@property (assign, nonatomic) GHTestOptions options;
 92
 93/*!
 94 Create an empty test group.
 95 @param name The name of the test group
 96 @param delegate Delegate, notifies of test start and end
 97 @result New test group
 98 */
 99- (id)initWithName:(NSString *)name delegate:(id<GHTestDelegate>)delegate;
100
101/*!
102 Create test group from a test case.
103 @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
104 @param delegate Delegate, notifies of test start and end
105 @result New test group
106 */
107- (id)initWithTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate;
108
109/*!
110 Create test group from a single test.
111 @param testCase
112 @param selector Test to run 
113 @param delegate
114 */
115- (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id<GHTestDelegate>)delegate;
116
117/*!
118 Create test group from a test case.
119 @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
120 @param delegate Delegate, notifies of test start and end
121 @result New test group
122 */
123+ (GHTestGroup *)testGroupFromTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate;
124
125/*!
126 Add a test case (or test group) to this test group.
127 @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
128 */
129- (void)addTestCase:(id)testCase;
130
131/*!
132 Add a test group to this test group.
133 @param testGroup Test group to add
134 */
135- (void)addTestGroup:(GHTestGroup *)testGroup;
136
137/*!
138 Add tests to this group.
139 @param tests Tests to add
140 */
141- (void)addTests:(NSArray */*of id<GHTest>*/)tests;
142
143/*!
144 Add test to this group.
145 @param test Test to add
146 */
147- (void)addTest:(id<GHTest>)test;
148
149/*!
150 Whether the test group should run on the main thread.
151 Call passes to test case instance if enabled.
152 */
153- (BOOL)shouldRunOnMainThread;
154
155/*!
156 @result YES if we have any enabled chilren, NO if all children have been disabled.
157 */
158- (BOOL)hasEnabledChildren;
159
160/*!
161 Get list of failed tests.
162 @result Failed tests
163 */
164- (NSArray */*of id<GHTest>*/)failedTests;
165
166/*!
167 Run in operation queue.
168 Tests from the group are added and will block until they have completed.
169 @param operationQueue If nil, then runs as is
170 @param options Options
171 */
172- (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOptions)options;
173
174@end
175
176//! @endcond