I want to create a test for the method bellow, I would like to check if the forgot password is right. I'm new on TDD and I would like to know if you guys think this is necessary and how could I implement the test.
- (IBAction)forgotPasswordButtonClicked:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:kForgetPasswordURL]];
}
Thanks a lot
For OCMock 3, try the following:
id mockApplication = OCMClassMock([UIApplication class]);
OCMStub([mockApplication sharedApplication]).andReturn(mockApplication);
OCMVerify([mockApplication openURL:[OCMArg any]]);
This article helped me out.
I deleted the new class with the static method and to solve my problem I used a partial mock from the Specta framework:
id mockApplication = [OCMockObject partialMockForObject:[UIApplication sharedApplication]];
I guess this is a better solution. (I didn't know partial mocks before)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With