-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to Latest OCMock, Demonstrate Improved Unit Testing #347
Conversation
} | ||
|
||
[cv layoutIfNeeded]; | ||
XCTAssertEqualObjects(attr, [cv layoutAttributesForSupplementaryElementOfKind:@"SuppKind" atIndexPath:indexPath]); | ||
XCTAssertEqual(view, [cv supplementaryViewForElementKind:@"SuppKind" atIndexPath:indexPath]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, under the new OCMock, if an exception is thrown while inside a mock object method, and you later verify, it will fail and report that an exception was thrown. So we will have to avoid verifying after testing exception-throwing, which is sucky but not worth holding back on OCMock 2.2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - And the I really like the new syntax!
…roup#347) * Update OCMock 2.2 -> 3.4 * Clean up and port ASMultiplexImageNodeTests * Clean up * Be stricter about order * Log change * Update the licenses #important * Update the license headers more
Unit tests are great! tl;dr: This diff migrates us from OCMock 2.2 to 3.4, and migrates ASMultiplexImageNodeTests to the latest syntax as a demonstration.
imageForImageIdentifier:
twice if the first time it returns nil. Now [ASMultiplexImageNode] imageForImageIdentifier: Method May Be Called Multiple Times if First Call Returns Nil #346.[[[mockCache expect] andDo:^(NSInvocation *inv) { … }] imageForImageID:OCMOCK_ANY];
OCMExpect([mockCache imageForImageID:OCMOCK_ANY]).andDo(^(NSInvocation *inv) { … });
NSInvocation+OCMAdditions
file is no longer public, so I created a mini version of those methodsNSInvocation+ASTestHelpers
that is actually safer under ARC.-tearDown
includesOCMVerifyAll
of all mocks created in-setUp
.OCMExpect
and run their code, validation is done for them.-setUp
setsexpectationOrderMatters
on all mocks. Test methods can clear this flag if they need to, but they shouldn't.OCMExpect
instead, unless you're really sure the method sequence is irrelevant._mockCache
->mockCache
.Note: The indentation style for chained macros may seem strange to you (I quite like it), but it's the Xcode default: