Created
March 1, 2014 02:54
-
-
Save NicholasTD07/9284385 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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