i'm struggling with checking wether a method get called or not:
In my controller i have the method, which should call a method in the AppDelegate:
- (IBAction) startButtonClicked:(id)sender {
AppDelegate *app = (AppDelegate*) [[NSApplication sharedApplication] delegate];
[app startCreateNewAppModuleClicked];
}
here is my AppDelegate method:
- (void) startCreateNewAppModuleClicked {
NSLog(@"Test");
}
and here is the test i wrote:
- (void)setUp
{
[super setUp];
appDelegateMock = [OCMockObject mockForClass:AppDelegate.class];
createNewAppWindowControllerMock = [OCMockObject mockForClass:CreateNewAppWindowController.class];
}
- (void)tearDown
{
[super tearDown];
}
- (void) testCreateNewAppModuleWhenStartButtonClicked {
[[appDelegateMock expect] startCreateNewAppModuleClicked];
[createNewAppWindowControllerMock startButtonClicked:nil];
[appDelegateMock verify];
}
I tried different approaches but never get the test passed. Either i get a "Wrong method invoked" Fail or a "Method not called" Fail.
Thanks
tobi