views:

25

answers:

1

Hi,

I have successfully set up unit testing for an XCode version 3.2.2 project with the iPhone SDK version 3.1.2.

I have created a class, "Callout" which I am attempting to instantiate within the context of a unit test. The class has a method,

-(id) initWithDictionary:(NSDictionary*)calloutDict includesSong:(BOOL)hasSong lastUpdate:(NSDate*)lastUpdate;

which I am calling in the unit test. When I do so, I get the error "Unrecognized instance sent to selector". This didn't make any sense to me, so out of curiosity I left everything the same and passed 'nil' in as the dictionary parameter, and it built and ran (failing the test of course, but it ran nonetheless).

Does anybody have any clue what's happening here? I don't think there is anything wrong with using a custom data type in OCUnit, since I successfully did it elsewhere in the unit tests.

Here is the offending code, by the way:

- (void)testCalloutNormal
{ 
 NSDictionary *params = [[NSDictionary alloc] initWithObjects:[NSMutableArray arrayWithObjects:@"sent", 
                  [NSNumber numberWithInt:100], 
                  [NSNumber numberWithInt:50], 
                  @"challengerUsername", 
                  @"challengedUsername", 
                  [NSDate date], 
                  nil] 
               forKeys:[NSMutableArray arrayWithObjects:@"type", 
                  @"challengerScore", 
                  @"challengedScore", 
                  @"challenger", 
                  @"challenged", 
                  @"dateAccepted", 
                  nil]];
 Callout *callout;
 callout = [[Callout alloc] initWithDictionary:params includesSong:NO lastUpdate:[NSDate date]];
 NSInteger ID = 1;
 callout.calloutID = 1;
 [params release];


 STAssertEquals(CalloutOutcomeTypeWon, callout.outcome, @"Failure: challenger's score is higher than the challengee - should return CalloutOutcomeTypeWon");

}

Thanks!

-Matt

P.S. - Most threads I have found related to OCUnit usually involve the suggestion of some supposedly better unit testing framework. I am aware that they are out there, but I'm not really interested unless you have anything different than GHUnit or the Google toolbox for Mac.