iut 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/bin/iut +2 -0
- data/iut.gemspec +24 -0
- data/lib/iut.rb +17 -0
- data/lib/iut/generator.rb +28 -0
- data/lib/iut/version.rb +4 -0
- data/template/project/iUnitTest/iUnitTest.xcodeproj/project.pbxproj +480 -0
- data/template/project/iUnitTest/iUnitTest/Classes/.do_not_remove_this_directory +0 -0
- data/template/project/iUnitTest/iUnitTest/Tests/.do_not_remove_this_directory +0 -0
- data/template/project/iUnitTest/iUnitTest/en.lproj/InfoPlist.strings +2 -0
- data/template/project/iUnitTest/iUnitTest/iUnitTest-Info.plist +44 -0
- data/template/project/iUnitTest/iUnitTest/iUnitTest-Prefix.pch +14 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Default.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTAppDelegate.h +20 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTAppDelegate.m +38 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTDetailView.xib +184 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTMainWindow.xib +732 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/IUTTestView.xib +432 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/Japanese.lproj/Root.strings +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/Root.plist +39 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/Settings.bundle/en.lproj/Root.strings +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgent.h +33 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgent.m +135 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/AppAgentHelper.h +63 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UINavigationBarBasedTest.h +25 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UINavigationBarBasedTest.m +49 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarAndNavigationBarBasedTest.h +23 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarAndNavigationBarBasedTest.m +42 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarBasedTest.h +25 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITabBarBasedTest.m +50 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewBasedTest.h +23 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewBasedTest.m +57 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewControllerTest.h +22 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UITableViewControllerTest.m +44 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewBasedTest.h +21 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewBasedTest.m +52 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewControllerTest.h +63 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/ControllerTest/UIViewControllerTest.m +162 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/GTMSenTestCase.h +17 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/GTMSenTestCase.m +15 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertion.h +135 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertion.m +216 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertionInfo.h +60 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTAssertionInfo.m +104 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTDetailViewController.h +24 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTDetailViewController.m +81 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTLog.h +14 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTPreference.h +34 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTPreference.m +125 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewCell.h +27 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewCell.m +83 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewController.h +26 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTResultTableViewController.m +193 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTest.h +74 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTest.m +127 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunner.h +66 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunner.m +449 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunnerViewController.h +59 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/IUTTestRunnerViewController.m +163 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/NSExceptionExtension.h +21 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/NSExceptionExtension.m +52 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SenTestAssertion.h +82 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SourceCodeOpener.h +65 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/SourceCodeOpener.m +176 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/UnitTest/UITableViewControllerTestHelper.h +35 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/isd_logo_60x40.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/isd_logo_60x40_w.png +0 -0
- data/template/project/iUnitTest/iUnitTest/iunittest/iunittest_icon.png +0 -0
- data/template/project/iUnitTest/iUnitTest/main.m +18 -0
- data/template/project/iUnitTest/script/sync_source.rb +27 -0
- metadata +119 -0
@@ -0,0 +1,449 @@
|
|
1
|
+
//
|
2
|
+
// IUTTestRunner.m
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/16.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import "IUTTestRunner.h"
|
10
|
+
#import "IUTTest.h"
|
11
|
+
#import "/usr/include/objc/objc-class.h"
|
12
|
+
#import "IUTLog.h"
|
13
|
+
#import "IUTPreference.h"
|
14
|
+
#import "NSExceptionExtension.h"
|
15
|
+
|
16
|
+
|
17
|
+
@interface IUTTestRunner(_private)
|
18
|
+
- (BOOL)isSubclassOf:(Class)class;
|
19
|
+
- (void)collectTestSites;
|
20
|
+
- (void)performSelectorWithSelectorAndTargetArray:(NSArray *)arg;
|
21
|
+
- (void)performSelectorOnMainThread:(NSString *)selectorString target:(id)target;
|
22
|
+
- (void)performSelectorWithSelectorAndTargetArray2:(NSArray *)arg;
|
23
|
+
- (void)performSelectorOnMainThread2:(NSString *)selectorString target:(id)target;
|
24
|
+
- (void)runSetUp:(IUTTest *)site;
|
25
|
+
- (void)runSetUpSequence:(IUTTest *)site;
|
26
|
+
- (void)runTest:(IUTTest *)site selector:(NSString *)testSel;
|
27
|
+
- (void)runTearDown:(IUTTest *)site;
|
28
|
+
- (void)wait:(NSTimeInterval)time;
|
29
|
+
@end
|
30
|
+
|
31
|
+
@implementation IUTTestRunner
|
32
|
+
|
33
|
+
@synthesize sites, tests, passes, fails, errors, exception;
|
34
|
+
|
35
|
+
- (id)init
|
36
|
+
{
|
37
|
+
self = [super init];
|
38
|
+
if (self) {
|
39
|
+
sites = [NSMutableArray new];
|
40
|
+
passes = [NSMutableArray new];
|
41
|
+
fails = [NSMutableArray new];
|
42
|
+
errors = [NSMutableArray new];
|
43
|
+
tests = [NSMutableArray new];
|
44
|
+
[self collectTestSites];
|
45
|
+
}
|
46
|
+
return self;
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
- (void)dealloc
|
51
|
+
{
|
52
|
+
[exception release];
|
53
|
+
[tests release];
|
54
|
+
[sites release];
|
55
|
+
[passes release];
|
56
|
+
[fails release];
|
57
|
+
[errors release];
|
58
|
+
[super dealloc];
|
59
|
+
}
|
60
|
+
|
61
|
+
- (BOOL)isSubclassOf:(Class)class
|
62
|
+
{
|
63
|
+
if (class_isMetaClass(class) == NO) {
|
64
|
+
Class testclass = [IUTTest class];
|
65
|
+
Class superclass = class_getSuperclass(class);
|
66
|
+
while (superclass != Nil) {
|
67
|
+
if (superclass->isa == testclass->isa) {
|
68
|
+
if (class->isa != testclass->isa) {
|
69
|
+
return YES;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
superclass = class_getSuperclass(superclass);
|
73
|
+
}
|
74
|
+
}
|
75
|
+
return NO;
|
76
|
+
}
|
77
|
+
|
78
|
+
- (void)collectTestSites
|
79
|
+
{
|
80
|
+
int count;
|
81
|
+
Class *classes = NULL;
|
82
|
+
Class *classPtr;
|
83
|
+
|
84
|
+
count = objc_getClassList(NULL, 0);
|
85
|
+
|
86
|
+
if (count > 0) {
|
87
|
+
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
88
|
+
classes = malloc(sizeof(Class) * count);
|
89
|
+
count = objc_getClassList(classes, count);
|
90
|
+
classPtr = classes;
|
91
|
+
for (int i = 0; i < count; i++, classPtr++) {
|
92
|
+
Class aClass = *classPtr;
|
93
|
+
if ([self isSubclassOf:aClass]) {
|
94
|
+
IUTTest *site = (IUTTest *)[[aClass new] autorelease];
|
95
|
+
if ([site.tests count]) {
|
96
|
+
[sites addObject:site];
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
free(classes);
|
101
|
+
[pool release];
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
- (NSString *)result
|
107
|
+
{
|
108
|
+
NSMutableString *str = [NSMutableString string];
|
109
|
+
int count;
|
110
|
+
|
111
|
+
count = [tests count];
|
112
|
+
[str appendFormat:(count > 1) ? @"%d tests" : @"%d test", count];
|
113
|
+
count = self.assertedCount;
|
114
|
+
[str appendFormat:(count > 1) ? @", %d assertions" : @", %d assertion", count];
|
115
|
+
count = [fails count];
|
116
|
+
[str appendFormat:(count > 1) ? @", %d failures" : @", %d failure", count];
|
117
|
+
count = [errors count];
|
118
|
+
[str appendFormat:(count > 1) ? @", %d errors" : @", %d error", count];
|
119
|
+
return str;
|
120
|
+
}
|
121
|
+
|
122
|
+
- (int)assertedCount
|
123
|
+
{
|
124
|
+
int count = 0;
|
125
|
+
for (IUTTest *site in sites) {
|
126
|
+
count += site.assertedCount;
|
127
|
+
}
|
128
|
+
return count;
|
129
|
+
}
|
130
|
+
|
131
|
+
- (int)allTestCount
|
132
|
+
{
|
133
|
+
int count = 0;
|
134
|
+
for (IUTTest *site in sites) {
|
135
|
+
count += [site.tests count];
|
136
|
+
}
|
137
|
+
return count;
|
138
|
+
}
|
139
|
+
|
140
|
+
- (int)badgeNumber
|
141
|
+
{
|
142
|
+
return [fails count] + [errors count];
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
#pragma mark -
|
147
|
+
#pragma mark query result
|
148
|
+
|
149
|
+
- (BOOL)isPassed
|
150
|
+
{
|
151
|
+
return !self.hasErrors && !self.hasFailures && [self.passes count];
|
152
|
+
}
|
153
|
+
|
154
|
+
- (BOOL)hasErrors
|
155
|
+
{
|
156
|
+
return [self.errors count];
|
157
|
+
}
|
158
|
+
|
159
|
+
- (BOOL)hasFailures
|
160
|
+
{
|
161
|
+
return [self.fails count];
|
162
|
+
}
|
163
|
+
|
164
|
+
|
165
|
+
#pragma mark -
|
166
|
+
#pragma mark colors
|
167
|
+
|
168
|
+
+ (UIColor *)successColor
|
169
|
+
{
|
170
|
+
return [UIColor colorWithRed:128.0 / 255.0 green:255.0 / 255.0 blue:0.0 / 255.0 alpha:1.0]; // Lime
|
171
|
+
}
|
172
|
+
|
173
|
+
+ (UIColor *)failureColor
|
174
|
+
{
|
175
|
+
return [UIColor yellowColor];
|
176
|
+
}
|
177
|
+
|
178
|
+
+ (UIColor *)failureColor2
|
179
|
+
{
|
180
|
+
return [self successColor];
|
181
|
+
}
|
182
|
+
|
183
|
+
+ (UIColor *)errorColor
|
184
|
+
{
|
185
|
+
return [UIColor redColor];
|
186
|
+
}
|
187
|
+
|
188
|
+
+ (UIColor *)idleColor
|
189
|
+
{
|
190
|
+
return [UIColor colorWithRed:230.0 / 255.0 green:230.0 / 255.0 blue:230.0 / 255.0 alpha:1.0]; // Mercury
|
191
|
+
}
|
192
|
+
|
193
|
+
- (UIColor *)successColor
|
194
|
+
{
|
195
|
+
return [[self class] successColor];
|
196
|
+
}
|
197
|
+
|
198
|
+
- (UIColor *)failureColor
|
199
|
+
{
|
200
|
+
return [[self class] failureColor];
|
201
|
+
}
|
202
|
+
|
203
|
+
- (UIColor *)failureColor2
|
204
|
+
{
|
205
|
+
return [[self class] failureColor2];
|
206
|
+
}
|
207
|
+
|
208
|
+
- (UIColor *)errorColor
|
209
|
+
{
|
210
|
+
return [[self class] errorColor];
|
211
|
+
}
|
212
|
+
|
213
|
+
- (UIColor *)idleColor
|
214
|
+
{
|
215
|
+
return [[self class] idleColor];
|
216
|
+
}
|
217
|
+
|
218
|
+
- (UIColor *)backgroundColor
|
219
|
+
{
|
220
|
+
if (self.hasErrors) {
|
221
|
+
return self.errorColor;
|
222
|
+
} else
|
223
|
+
if (self.hasFailures) {
|
224
|
+
return self.failureColor;
|
225
|
+
} else
|
226
|
+
if (self.isPassed) {
|
227
|
+
return self.successColor;
|
228
|
+
}
|
229
|
+
return self.idleColor;
|
230
|
+
}
|
231
|
+
|
232
|
+
|
233
|
+
#pragma mark -
|
234
|
+
#pragma mark execute tests
|
235
|
+
|
236
|
+
- (void)performSelectorWithSelectorAndTargetArray:(NSArray *)arg
|
237
|
+
{
|
238
|
+
SEL selector = NSSelectorFromString([arg objectAtIndex:0]);
|
239
|
+
id target = [arg objectAtIndex:1];
|
240
|
+
@try {
|
241
|
+
[target performSelector:selector];
|
242
|
+
}
|
243
|
+
@catch (NSException * e) {
|
244
|
+
self.exception = e;
|
245
|
+
}
|
246
|
+
}
|
247
|
+
|
248
|
+
- (void)performSelectorOnMainThread:(NSString *)selectorString target:(id)target
|
249
|
+
{
|
250
|
+
NSArray *arg = [[NSArray alloc] initWithObjects:selectorString, target, nil];
|
251
|
+
[self performSelectorOnMainThread:@selector(performSelectorWithSelectorAndTargetArray:) withObject:arg waitUntilDone:YES];
|
252
|
+
[arg release];
|
253
|
+
}
|
254
|
+
|
255
|
+
- (void)performSelectorWithSelectorAndTargetArray2:(NSArray *)arg
|
256
|
+
{
|
257
|
+
SEL selector = NSSelectorFromString([arg objectAtIndex:0]);
|
258
|
+
id target = [arg objectAtIndex:1];
|
259
|
+
@try {
|
260
|
+
delay = [[target performSelector:selector] doubleValue];
|
261
|
+
}
|
262
|
+
@catch (NSException * e) {
|
263
|
+
self.exception = e;
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
- (void)performSelectorOnMainThread2:(NSString *)selectorString target:(id)target
|
268
|
+
{
|
269
|
+
NSArray *arg = [[NSArray alloc] initWithObjects:selectorString, target, nil];
|
270
|
+
[self performSelectorOnMainThread:@selector(performSelectorWithSelectorAndTargetArray2:) withObject:arg waitUntilDone:YES];
|
271
|
+
[arg release];
|
272
|
+
}
|
273
|
+
|
274
|
+
|
275
|
+
- (void)runSetUp:(IUTTest *)site
|
276
|
+
{
|
277
|
+
IUTLog(@" setUp");
|
278
|
+
[self performSelectorOnMainThread2:@"willSetUp" target:site];
|
279
|
+
if (self.exception) @throw self.exception;
|
280
|
+
[self wait:delay];
|
281
|
+
|
282
|
+
[self performSelectorOnMainThread:@"setUp" target:site];
|
283
|
+
if (self.exception) @throw self.exception;
|
284
|
+
[self wait:delay];
|
285
|
+
|
286
|
+
[self performSelectorOnMainThread2:@"didSetUp" target:site];
|
287
|
+
if (self.exception) @throw self.exception;
|
288
|
+
[self wait:delay];
|
289
|
+
}
|
290
|
+
|
291
|
+
- (void)runSetUpSequence:(IUTTest *)site
|
292
|
+
{
|
293
|
+
IUTLog(@" setUpSequence");
|
294
|
+
|
295
|
+
// next test
|
296
|
+
while(site.nextSetUpSequence) {
|
297
|
+
SEL aSelector = site.nextSetUpSequence;
|
298
|
+
site.nextSetUpSequence = NULL;
|
299
|
+
[self wait:site.nextSetUpSequenceAfterDelay];
|
300
|
+
|
301
|
+
IUTLog(@" %@", NSStringFromSelector(aSelector));
|
302
|
+
[self performSelectorOnMainThread:NSStringFromSelector(aSelector) target:site];
|
303
|
+
if (self.exception) {
|
304
|
+
@throw self.exception;
|
305
|
+
}
|
306
|
+
}
|
307
|
+
}
|
308
|
+
|
309
|
+
- (void)runTest:(IUTTest *)site selector:(NSString *)testSel
|
310
|
+
{
|
311
|
+
IUTLog(@" test");
|
312
|
+
|
313
|
+
[self performSelectorOnMainThread:testSel target:site];
|
314
|
+
if (self.exception) @throw self.exception;
|
315
|
+
|
316
|
+
// next test
|
317
|
+
while(site.nextTest) {
|
318
|
+
SEL aSelector = site.nextTest;
|
319
|
+
site.nextTest = NULL;
|
320
|
+
[self wait:site.nextTestAfterDelay];
|
321
|
+
|
322
|
+
IUTLog(@" %@", NSStringFromSelector(aSelector));
|
323
|
+
[self performSelectorOnMainThread:NSStringFromSelector(aSelector) target:site];
|
324
|
+
if (self.exception) {
|
325
|
+
@throw self.exception;
|
326
|
+
}
|
327
|
+
}
|
328
|
+
}
|
329
|
+
|
330
|
+
- (void)runTearDown:(IUTTest *)site
|
331
|
+
{
|
332
|
+
self.exception = nil;
|
333
|
+
|
334
|
+
IUTLog(@" tearDown");
|
335
|
+
@try {
|
336
|
+
[self performSelectorOnMainThread2:@"willTearDown" target:site];
|
337
|
+
[self wait:delay];
|
338
|
+
} @finally {
|
339
|
+
@try {
|
340
|
+
[self performSelectorOnMainThread:@"tearDown" target:site];
|
341
|
+
} @finally {
|
342
|
+
@try {
|
343
|
+
[self performSelectorOnMainThread2:@"didTearDown" target:site];
|
344
|
+
[self wait:delay];
|
345
|
+
} @finally {
|
346
|
+
if (self.exception) @throw self.exception;
|
347
|
+
}
|
348
|
+
}
|
349
|
+
}
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
- (void)wait:(NSTimeInterval)time
|
355
|
+
{
|
356
|
+
if (time != 0.0) {
|
357
|
+
[NSThread sleepForTimeInterval:time];
|
358
|
+
}
|
359
|
+
}
|
360
|
+
|
361
|
+
- (void)run:(id)sender
|
362
|
+
{
|
363
|
+
NSAutoreleasePool *pool = [NSAutoreleasePool new];
|
364
|
+
[tests removeAllObjects];
|
365
|
+
[passes removeAllObjects];
|
366
|
+
[fails removeAllObjects];
|
367
|
+
[errors removeAllObjects];
|
368
|
+
|
369
|
+
stopRequest = NO;
|
370
|
+
|
371
|
+
[sender performSelectorOnMainThread:@selector(willTest:) withObject:nil waitUntilDone:YES];
|
372
|
+
|
373
|
+
float count = (float)[self allTestCount];
|
374
|
+
int i = 0;
|
375
|
+
IUTPreference *preference = [IUTPreference sharedPreference];
|
376
|
+
|
377
|
+
for (IUTTest *site in sites) {
|
378
|
+
NSString *siteName = NSStringFromClass([site class]);
|
379
|
+
IUTLog(@"%@", siteName);
|
380
|
+
[site clearAssertedCount];
|
381
|
+
for (NSString *testSel in site.tests) {
|
382
|
+
if (stopRequest) {
|
383
|
+
goto ABORT_TEST;
|
384
|
+
}
|
385
|
+
if (![preference needsTest:siteName methodName:testSel]) {
|
386
|
+
// DEBUGME: IUTLog(@" %@ was skiped", testSel);
|
387
|
+
continue;
|
388
|
+
}
|
389
|
+
|
390
|
+
@try {
|
391
|
+
IUTLog(@" %@", testSel);
|
392
|
+
[tests addObject:testSel];
|
393
|
+
|
394
|
+
[self runSetUp:site];
|
395
|
+
[self runSetUpSequence:site];
|
396
|
+
[self runTest:site selector:testSel];
|
397
|
+
|
398
|
+
[passes addObject:testSel];
|
399
|
+
[preference addPassedTest:siteName methodName:testSel];
|
400
|
+
} @catch (NSException * e) {
|
401
|
+
if ([e isFailure]) {
|
402
|
+
IUTLog(@" *** Fail:%@", e.assertionInfo.message);
|
403
|
+
[fails addObject:e];
|
404
|
+
} else {
|
405
|
+
NSException *anException = [IUTAssertion assertionErrorExceptionFrom:e klass:[site class] selectorName:testSel];
|
406
|
+
IUTLog(@" *** Error:%@", e.assertionInfo.message);
|
407
|
+
[errors addObject:anException];
|
408
|
+
}
|
409
|
+
} @finally {
|
410
|
+
@try {
|
411
|
+
[self runTearDown:site];
|
412
|
+
} @catch (NSException * e) {
|
413
|
+
|
414
|
+
NSException *anException = [IUTAssertion assertionErrorExceptionFrom:e klass:[site class] selectorName:testSel];
|
415
|
+
IUTLog(@" *** Error:%@", e.assertionInfo.message);
|
416
|
+
[errors addObject:anException];
|
417
|
+
|
418
|
+
} @finally {
|
419
|
+
i++;
|
420
|
+
[sender performSelectorOnMainThread:@selector(setProgress:) withObject:[NSNumber numberWithFloat:(float)i / (float)count] waitUntilDone:YES];
|
421
|
+
self.exception = nil;
|
422
|
+
}
|
423
|
+
}
|
424
|
+
}
|
425
|
+
}
|
426
|
+
|
427
|
+
ABORT_TEST:
|
428
|
+
|
429
|
+
// store result to preference
|
430
|
+
if (self.isPassed) {
|
431
|
+
[preference clearPassedTests];
|
432
|
+
}
|
433
|
+
[preference synchronize];
|
434
|
+
|
435
|
+
// notify didTest
|
436
|
+
[sender performSelectorOnMainThread:@selector(didTest:) withObject:nil waitUntilDone:YES];
|
437
|
+
|
438
|
+
[pool release];
|
439
|
+
[NSThread exit];
|
440
|
+
}
|
441
|
+
|
442
|
+
- (void)stop:(id)sender
|
443
|
+
{
|
444
|
+
stopRequest = YES;
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
@end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
//
|
2
|
+
// IUTTestRunnerViewController.h
|
3
|
+
// iUnitTest
|
4
|
+
//
|
5
|
+
// Created by Katsuyoshi Ito on 09/01/16.
|
6
|
+
// Copyright 2009 ITO SOFT DESIGN Inc. All rights reserved.
|
7
|
+
//
|
8
|
+
|
9
|
+
#import <UIKit/UIKit.h>
|
10
|
+
#import "IUTTestRunner.h"
|
11
|
+
#import "IUTResultTableViewController.h"
|
12
|
+
|
13
|
+
|
14
|
+
@interface IUTTestRunnerViewController : UIViewController {
|
15
|
+
|
16
|
+
IBOutlet UIProgressView *progressView;
|
17
|
+
IBOutlet UIButton *startStopButton;
|
18
|
+
IBOutlet UIActivityIndicatorView *indicatorView;
|
19
|
+
IBOutlet UILabel *resultLabel;
|
20
|
+
IBOutlet IUTResultTableViewController *resultTestViewController;
|
21
|
+
IBOutlet UIBarButtonItem *allButton;
|
22
|
+
|
23
|
+
BOOL running;
|
24
|
+
|
25
|
+
IUTTestRunner *runner;
|
26
|
+
|
27
|
+
}
|
28
|
+
|
29
|
+
@property (retain) IBOutlet UIProgressView *progressView;
|
30
|
+
@property (retain) IBOutlet UIButton *startStopButton;
|
31
|
+
@property (retain) IBOutlet UIActivityIndicatorView *indicatorView;
|
32
|
+
@property (retain) IBOutlet UILabel *resultLabel;
|
33
|
+
@property (retain) IBOutlet IUTResultTableViewController *resultTestViewController;
|
34
|
+
@property (retain) IBOutlet UIBarButtonItem *allButton;
|
35
|
+
|
36
|
+
|
37
|
+
@property (getter=isRunning) BOOL running;
|
38
|
+
|
39
|
+
@property (retain, readonly) IUTTestRunner *runner;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
- (IBAction)startStopAction:(id)sender;
|
44
|
+
- (IBAction)startAction:(id)sender;
|
45
|
+
- (IBAction)stopAction:(id)sender;
|
46
|
+
|
47
|
+
- (IBAction)clearPassedTestsAction:(id)sender;
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
- (void)setButtonTitle:(NSString *)title;
|
52
|
+
|
53
|
+
- (void)setProgress:(NSNumber *)value;
|
54
|
+
- (void)willTest:(id)sender;
|
55
|
+
- (void)didTest:(id)sender;
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
@end
|