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

Automatically stop all live mocks at the end of each test case #394

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

Commits on Jan 2, 2021

  1. Automatically stop all live mocks at the end of each test case/suite

    If the user is using XCTest with OCMock, this registers a test observer that takes care
    of stopping all live mocks appropriately.
    
    For mocks that are created in +setUp, those will get stopped at the end of the suite.
    For mocks that are created in -setUp or in test cases themselves, those will get
    stopped at the end of the testcase.
    
    While these mocks are being stopped and testcases/suites are being torndown, messages
    sent to mocks are not going to trigger the exception about calling a mock after it has
    had stopMocking called on it. This allows objects that may refer to mocks in dealloc
    methods to be cleaned up in autoreleasepools or due to stopMocking being called
    without the mocks throwing exceptions.
    
    This should greatly simplify cleaning up mocks and remove a lot of potential leakage.
    It also makes sure that class mocks that mock class methods will not persist across tests.
    dmaclach committed Jan 2, 2021
    Configuration menu
    Copy the full SHA
    584002a View commit details
    Browse the repository at this point in the history