Skip to content
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

Potential solution for testing optional methods on protocol mocks where we want to control -respondsToSele… #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 23, 2015

  1. Potential solution for mocks where we want to control -respondsToSele…

    …ctor:. Problem noted at http://stackoverflow.com/questions/11923942/ocmock-mocking-protocols-with-excluding-optional-methods .  I want to test a class which has a delegate, and the behavior should be tested for situations where the delegate implements an optional method and also when it does not.  I could not figure out a way to do this with OCMock other than implementing a slew of individual classes which implement only the desired combination of methods for a particular test.  This approach is a subclass of OCProtocolMockObject, which implements -respondsToSelector: based on if there are any stubs, expects, or rejects added to the mock.  This way a unit test can control respondsTo status just by manipulating the expects or the stubs.  It is not a nice mock, so unexpected calls should still cause exceptions.  I'm not sure a "nice" version would make any sense, but it wouldn't to be hard to add if my imagination is just missing something.
    carllindberg committed Sep 23, 2015
    Configuration menu
    Copy the full SHA
    c9eb38f View commit details
    Browse the repository at this point in the history