Welcome to the documentation for XCTest+OHHTTPStubSuiteCleanUp! This page will provide you with all the information you need to get started and make the most of this library.

About XCTest+OHHTTPStubSuiteCleanUp

XCTest+OHHTTPStubSuiteCleanUp is a helpful library that extends XCTest framework to provide additional functionalities for unit testing in iOS projects. It integrates with OHHTTPStubs, a popular library for stubbing network requests, to simplify the process of cleaning up stubs after each test suite.


To install XCTest+OHHTTPStubSuiteCleanUp, follow the steps below:

  • Add the library to your Xcode project using CocoaPods or Manually
  • Import the XCTest+OHHTTPStubSuiteCleanUp module in your test files
  • Ensure OHHTTPStubs is integrated in your project, as XCTest+OHHTTPStubSuiteCleanUp depends on it


Using XCTest+OHHTTPStubSuiteCleanUp is easy. Simply follow the steps below:

  1. Start by importing the XCTest+OHHTTPStubSuiteCleanUp module in your test files
  2. Create a subclass of XCTestCase and include OHHTTPStubSuiteCleanUp
  3. Override the ‘setUp’ and ‘tearDown’ methods to configure and clean up stubs for each test
  4. Use ‘httpStubSuiteCleanUp()’ method inside ‘tearDown’ to clean up the stubs
  5. Add your unit tests within the subclass as usual
  6. Run your tests and observe the stubs being properly cleaned up between test runs


Here’s a simple example to illustrate how to use XCTest+OHHTTPStubSuiteCleanUp:

// Import required modules
import XCTest
import XCSTestCase
import OHHTTPStubs
import XCTest+OHHTTPStubSuiteCleanUp

class MyAPITests: XCTestCase, OHHTTPStubSuiteCleanUp {
    // Set up the stubs for each test
    override func setUp() {
        // Stub network requests using OHHTTPStubs
        // ... your stub configurations ...
    // Cleanup the stubs after each test
    override func tearDown() {
        httpStubSuiteCleanUp() // Clean up stubs
    // Write your unit tests here
    func testAPICall() {
        // ... your test assertions ...
    // ... more test methods ...

Further Resources

For more information on using XCTest+OHHTTPStubSuiteCleanUp and OHHTTPStubs, you can refer to the following resources: