Integrating unit testing into an existing app
Integrating unit testing into an existing app
- Subject: Integrating unit testing into an existing app
- From: email@hidden
- Date: Mon, 10 May 2010 15:33:44 +0000
I'm trying to integrate unit testing (OCMock) into an existing application and have run into a problem that I'm not sure how to resolve. Below is some test code that should verify that a couple of methods are actually called. Below that is the actual code being tested (not fully yet, just trying to understand things). The test fails and I'm not sure why or how to troubleshoot this. I found this page, http://tinyurl.com/ycgmmlc, which is the first non-trivial example of testing for objc that I've been able to find. It is the reference I've been using to design my tests. After running my tests, I get an error that the two method calls fail to be invoked. Here is the exact error:
2 expected methods were not invoked:
createStatusItemIcon:@"hk24.png"
createStatusItem
This program is about 3 years old, and these methods have never failed to be called in a running app, so I must be doing something wrong in the testing. Can someon provide me with a little help?
Thx
- (void)testApplicationDidFinishLaunching
{
AudioSwitcher *appDelegate =
[[[AudioSwitcher alloc] init] autorelease];
[appDelegate applicationDidFinishLaunching:nil];
id mockStatusItem = [OCMockObject mockForClass:[AudioSwitcher class]];
[[mockStatusItem expect] createStatusItemIcon:@"hk24.png"]; <--- fails
[[mockStatusItem expect] createStatusItem]; <--- fails
[mockStatusItem verify];
}
-(void)applicationDidFinishLaunching:(NSNotification *)aNotification{
OSStatus err;
[self createStatusItemIcon:@"hk24.png"];
[self createStatusItem];
// Menu items need to have a delegate
// set to receive the menus messages
[statusItem setTarget:self];
[statusItem setMenu:audioMenu];
[outputItem setTag:AS_OUTPUT_TAG];
[inputItem setTag:AS_INPUT_TAG];
[prefsItem setTarget:self];
[aboutItem setTarget:self];
[quitItem setTarget:self];
err = [self updateDeviceList];
[self setupDefaultIODevices];
[self buildMenu];
// install device notification callback
err = [self installHardwarePropertyListener];
if(err != noErr)
NSLog(@"Error installing hardware listener: %d", err);
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden