Search Results

Search found 6 results on 1 pages for 'ocmock'.

Page 1/1 | 1 

  • How to use mock and verify methods of OCMock in objective-C ? Is there any good tutorial on OCMock i

    - by san
    My problem is I am getting an error: OCMckObject[NSNumberFormatter]: expected method was not invoked:setAllowsFloats:YES I have written following Code: (void) testReturnStringFromNumber { id mockFormatter = [OCMockObject mockForClass:[NSNumberFormatter class]]; StringNumber *testObject = [[StringNumber alloc] init]; [[mockFormatter expect] setAllowsFloats:YES]; [testObject returnStringFromNumber:80.23456]; [mockFormatter verify]; } @implementation StringNumber - (NSString *) returnStringFromNumber:(float)num { NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; [formatter setAllowsFloats:YES]; NSString *str= [formatter stringFromNumber:[NSNumber numberWithFloat:num]]; [formatter release]; return str; } @end

    Read the article

  • OCmock and MKReverseGeocoder

    - by user315374
    Hi, I would like to test a method that uses reverse Geocoding. What i would like to do is : set the geocoder as a property of my controller create the geocoder in the init method call the geocoder in the method i want to test replace the geocoder with a mock in my test The problem is that the MKReverseGeocoder coordinate property is read only, i can only set it in the constructor method : [[MKReverseGeocoder alloc] initWithCoordinate:coord] And of course the coordinates are only available in the method i want to test.. Does anyone knows how i could mock the MKReverseGeocoder class ? Thanks in advance, Vincent.

    Read the article

  • How can I use OCMock to verify that a method is never called?

    - by Justin Voss
    At my day job I've been spoiled with Mockito's never() verification, which can confirm that a mock method is never called. Is there some way to accomplish the same thing using Objective-C and OCMock? I've been using the code below, which works but it feels like a hack. I'm hoping there's a better way... - (void)testSomeMethodIsNeverCalled { id mock = [OCMockObject mockForClass:[MyObject class]]; [[[mock stub] andCall:@selector(fail) onObject:self] forbiddenMethod]; // more test things here, which hopefully // never call [mock forbiddenMethod]... } - (void)fail { STFail(@"This method is forbidden!"); }

    Read the article

  • iphone OCMockObject and unit-testing a class that inherits from NSURLConnection

    - by Justin Galzic
    I want to unit test the custom init method of a class that inherits from NSURLConnection -- how would I do this if the init of my testable class invokes NSURLConnection's initWithRequest? I'm using OCMock and normally, I can mock objects that are contained within my test class. For this inheritance scenario, what's the best approach to do this? - (void)testInit { id urlRequest = [OCMockObject mockForClass:[NSURLRequest class]]; MyURLConnectionWrapper *conn = [[MyURLConnectionWrapper alloc] initWithRequest:urlRequest delegate:self someData:extraneousData]; } My class is implemented like this: @interface MyURLConnectionWrapper : NSURLConnection { } - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate someData:(NSString *)fooData @end @implementation MyURLConnectionWrapper - (id)initWithRequest:(NSURLRequest *)request delegate:(id)delegate someData:(NSString *)fooData { if (self = [super initWithRequest:request delegate:delegate]) { // do some additional work here } return self; } Here's the error I get: OCMockObject[NSURLRequest]: unexpected method invoked: _CFURLRequest

    Read the article

  • Unit tests only run automatically when active SDK is "simulator"?

    - by Steve Madsen
    I have followed the instructions Apple publishes for unit testing applications on iPhone and things work great when I set the active SDK to "iPhone Simulator". I have it configured to always build and run my tests as part of building the application itself. Apple implies (by omission) that this should work all of the time, but the tests are skipped when I set the active SDK to "iPhone Device". I am also linking with OCMock, and instead of a failing test, this warning is in the build log: ld: warning: in .../build/Debug-iphoneos/OCMock.framework/OCMock, missing required architecture arm in file It's very nice to make the unit test bundle a dependency of the main application, so these tests run at every build, but its utility is greatly diminished if it doesn't work during device builds. Is this a known, but undocumented, limitation?

    Read the article

  • [iPhone] dyld: Library not loaded - When app run from the command line

    - by user142764
    Hi, I face some difficulties when adding a framework to my project when i run an iPhone app from the command line. My final goal is to run applications tests from an automated build process. When i run my app from xCode : I add a "Copy File" build phase to my target and everything goes fine. The copy is set to $(BUILT_PRODUCTS_DIR) as "Absolute path" When i run my app from the terminal (using iphonesim project) i get this error : dyld: Library not loaded: @rpath/OCMock.framework/Versions/A/OCMock UIKitApplication:indemnisation[0xb894][26380] Referenced from: /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8/indemINT.app/indemINT What i dont understand is that the copy build phase just copies the framework files in the same directory that the app. When i run the app from the command line the framework files are already in the same directory. Does anyone knows why it doesn't work ? I've also tried to add the OCMock.framework in the following directories (without success) : /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/System/Library /Library/Frameworks /Users/Admin/Library/Application Support/iPhone Simulator/User/Applications/CD5729B5-A674-49B2-91F6-AD398094B6F8 Thanks in advance, Vincent.

    Read the article

1