Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save NicholasTD07/9284385 to your computer and use it in GitHub Desktop.
Save NicholasTD07/9284385 to your computer and use it in GitHub Desktop.
// Try this in 32bit and 64bit iOS Simulator.
// In 32bit one, both tests pass.
// In 64bit one, - (void)testStubWorksForYES fails.
// Test support
#import <XCTest/XCTest.h>
#define MOCKITO_SHORTHAND
#import <OCMockito/OCMockito.h>
@interface ReturningObject : UIViewController
- (BOOL)methodReturnsYES;
- (BOOL)methodReturnsNO;
@end
@implementation ReturningObject
- (BOOL)methodReturnsYES { return YES; }
- (BOOL)methodReturnsNO { return NO; }
@end
@interface OCMokitoTest : XCTestCase
@end
@implementation OCMokitoTest
{
ReturningObject *sut;
}
- (void)setUp
{
[super setUp];
// Put setup code here. This method is called before the invocation of each test method in the class.
sut = mock([ReturningObject class]);
}
- (void)testStubWorksForYES
{
// given
[given([sut methodReturnsNO]) willReturnBool:YES];
// then
XCTAssertTrue([sut methodReturnsNO], @"should be true.");
}
- (void)testStubWorksForNO
{
// given
[given([sut methodReturnsYES]) willReturnBool:NO];
// then
XCTAssertFalse([sut methodReturnsYES], @"should be False");
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment