Skip to content
This repository has been archived by the owner on Jun 5, 2018. It is now read-only.

iOS: Re-running a test should respect shouldRunOnMainThread. #76

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion Classes-iOS/GHUnitIOSTestViewController.h
Expand Up @@ -40,10 +40,11 @@
GHImageDiffView *imageDiffView_; GHImageDiffView *imageDiffView_;


GHTestNode *testNode_; GHTestNode *testNode_;
GHTestGroup *group_;


GHTestRunner *runner_; GHTestRunner *runner_;
} }


- (void)setTest:(id<GHTest>)test; - (void)setTest:(id<GHTest>)test group:(id<GHTest>)group;


@end @end
17 changes: 12 additions & 5 deletions Classes-iOS/GHUnitIOSTestViewController.m
Expand Up @@ -44,6 +44,7 @@ - (id)init {


- (void)dealloc { - (void)dealloc {
[testNode_ release]; [testNode_ release];
[group_ release];
[super dealloc]; [super dealloc];
} }


Expand All @@ -59,12 +60,16 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface
} }


- (void)_runTest { - (void)_runTest {
id<GHTest> test = [testNode_.test copyWithZone:NULL]; NSLog(@"Re-running: %@", group_);
NSLog(@"Re-running: %@", test);
[testView_ setText:@"Running..."]; [testView_ setText:@"Running..."];
[test run:GHTestOptionForceSetUpTearDownClass];
[self setTest:test]; id<GHTest> test = [testNode_.test copyWithZone:nil];
GHTestGroup* group = [[GHTestGroup alloc] initWithGroup:group_ test:test];
[group run:GHTestOptionForceSetUpTearDownClass];
[self setTest:test group:group];

[test release]; [test release];
[group release];
} }


- (void)_showImageDiff { - (void)_showImageDiff {
Expand Down Expand Up @@ -101,12 +106,14 @@ - (NSString *)updateTestView {
return text; return text;
} }


- (void)setTest:(id<GHTest>)test { - (void)setTest:(id<GHTest>)test group:(id<GHTest>)group {
[self view]; [self view];
self.title = [test name]; self.title = [test name];


[testNode_ release]; [testNode_ release];
testNode_ = [[GHTestNode nodeWithTest:test children:nil source:nil] retain]; testNode_ = [[GHTestNode nodeWithTest:test children:nil source:nil] retain];
[group_ release];
group_ = [group retain];
NSString *text = [self updateTestView]; NSString *text = [self updateTestView];
NSLog(@"%@", text); NSLog(@"%@", text);
} }
Expand Down
2 changes: 1 addition & 1 deletion Classes-iOS/GHUnitIOSViewController.m
Expand Up @@ -204,7 +204,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
GHTestNode *testNode = [[sectionNode children] objectAtIndex:indexPath.row]; GHTestNode *testNode = [[sectionNode children] objectAtIndex:indexPath.row];


GHUnitIOSTestViewController *testViewController = [[GHUnitIOSTestViewController alloc] init]; GHUnitIOSTestViewController *testViewController = [[GHUnitIOSTestViewController alloc] init];
[testViewController setTest:testNode.test]; [testViewController setTest:testNode.test group:sectionNode.test];
[self.navigationController pushViewController:testViewController animated:YES]; [self.navigationController pushViewController:testViewController animated:YES];
[testViewController release]; [testViewController release];
} }
Expand Down
4 changes: 4 additions & 0 deletions Classes/GHTest/GHTestGroup.h
Expand Up @@ -125,6 +125,10 @@
*/ */
- (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id<GHTestDelegate>)delegate; - (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id<GHTestDelegate>)delegate;



- (id)initWithGroup:(GHTestGroup*)group test:(id<GHTest>)test;


/*! /*!
Create test group from a test case. Create test group from a test case.
@param testCase Test case, could be a subclass of SenTestCase or GHTestCase @param testCase Test case, could be a subclass of SenTestCase or GHTestCase
Expand Down
10 changes: 10 additions & 0 deletions Classes/GHTest/GHTestGroup.m
Expand Up @@ -72,6 +72,16 @@ - (id)initWithTestCase:(id)testCase selector:(SEL)selector delegate:(id<GHTestDe
return self; return self;
} }


- (id)initWithGroup:(GHTestGroup*)group test:(id<GHTest>)test {
if ((self = [super init])) {
name_ = [group.name retain];
children_ = [[NSMutableArray arrayWithObject:test] retain];
delegate_ = group.delegate;
testCase_ = group.testCase;
}
return self;
}

+ (GHTestGroup *)testGroupFromTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate { + (GHTestGroup *)testGroupFromTestCase:(id)testCase delegate:(id<GHTestDelegate>)delegate {
return [[[GHTestGroup alloc] initWithTestCase:testCase delegate:delegate] autorelease]; return [[[GHTestGroup alloc] initWithTestCase:testCase delegate:delegate] autorelease];
} }
Expand Down