Created
July 22, 2010 11:38
-
-
Save lukeredpath/485866 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # potential syntatic sugar using a macro, which depends on yielding a specifically named builder param: | |
| #define expect(arg) [builder expect:arg] | |
| [context checking:^(LRExpectationBuilder *builder){ | |
| [expect(object) doSomething]; | |
| }]; |
This file contains hidden or 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
| @implementation MockeryTests | |
| - (void)setUp; | |
| { | |
| testCase = [MockTestCase new]; | |
| context = [LRMockery mockeryForTestCase:testCase]; | |
| } | |
| - (void)testCanExpectSingleMethodCallAndPass; | |
| { | |
| SimpleObject *testObject = [context mock:[SimpleObject class]]; | |
| [context checking:^(LRExpectationBuilder *will){ | |
| [[will expect:testObject] doSomething]; | |
| }]; | |
| [testObject doSomething]; | |
| [context assertSatisfied]; | |
| STAssertTrue([testCase numberOfFailures] == 0, @"expected zero failures, got %d.", [testCase numberOfFailures]); | |
| } | |
| - (void)testCanExpectSingleMethodCallAndFail; | |
| { | |
| SimpleObject *testObject = [context mock:[SimpleObject class]]; | |
| [context checking:^(LRExpectationBuilder *will){ | |
| [[will expect:testObject] doSomething]; | |
| }]; | |
| [context assertSatisfied]; | |
| STAssertTrue([testCase numberOfFailures] == 1, @"expected 1 failure, got %d.", [testCase numberOfFailures]); | |
| } | |
| @end |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The first passing functional tests for my Objective C jMock clone. Why another Obj-C mock library. Well, there's only one I know of (OCMock) and I sorry, I don't think its great. Why port jMock instead of a Ruby library like Mocha? As much as I like Mocha, I don't think its message-chaining syntax would work well with Obj-C (too many square brackets) so I've taken the jMock approach, which I think is elegant.