Asking for help / contributing

The best option to get help with using OCMock is to ask a question on StackOverflow using the ocmock tag.

Please open issues on Github only when you suspect that you have encountered a bug in OCMock. If you have a question about OCMock or you have an issue with using it in your project, please ask on StackOverflow.

Bug reports and pull requests are welcome. Please have a look at the contribution guidelines before opening one.

You can also contact the maintainer directly by email but please be aware that I am working on OCMock in my spare time and am unlikely to respond immediately.

Articles about mock objects

These articles, posts, and papers are not specifically about OCMock, but they are a good source of information on how to use a mock framework effectively.

Test Smell: Everything is mocked

A post that describes to common situations in which using mock objects may not be a great idea.

Don't mock types you don't own

Good discussion of when to use mock objects.

Mock Roles, not Objects [PDF]

A paper by the people who pioneered the use of mock objects. Covers a lot of the thinking behind sensible user of mock objects.

Tutorials for OCMock

The tutorials listed here were written independently and may or may not be up-to-date. Most of them are likely to use the traditional syntax, not the modern syntax introduced with OCMock 3.

OCMock Test Origami

Great introductory tutorial for OCMock.

Adding OCMock to your project

Short post that discusses several options to include OCMock in your projects. Includes a discussion of git submodules and CocoaPods.

Improving iOS Unit Tests with OCMock

Tutorial that discusses several more advanced aspects of using OCMock, including partial mocks.

iOS Unit Testing With OCMock

New tutorial, written in May 2013 for Xcode 4.6. Has a detailed description of the setup required for an iOS project and a longer example that shows how to test controllers and a non-trivial calculation.

Making Fun of Things with OCMock

Good introductory tutorial explaining the most used features. The installation notes in the first paragraph are not up-to-date anymore, please follow the instructions in this site instead.

Poking Objective-C with a Testing Stick

General tutorial that explains in detail how to set up a project for testing with OCUnit and OCMock. Also shows how partial mocks can be used to substitute individual methods in a test.

Testing Cocoa Controllers

A tutorial that shows how to test Cocoa controller objects without having to load the user interface from the NIB file. The objects defined in InterfaceBuilder are replaced with mocks.

Mocking Singletons with OCMock

The title says it all. Uses categories to allow substitution of system-provided singletons.

Writing custom constraints

OCMock integrates with Hamcrest but sometimes it can be easier to write a constraint using the API used by OCMock's built-in constraints. This tutorial shows how it's done. Applies to iPhone and Cocoa development.

OCMock and the iPhone

This tutorial shows how to use OCMock as a framework for an iPhone project. There are some limitations to this approach. Please visit the "iPhone/iOS" tab for more information.

Mocking a database connection

This tutorial describes a classic use case for mock objects, it shows how to replace a dependency on an external call with a mock object that returns canned values. This tutorial is in German.