Latest 0.1.2
Homepage https://github.com/cjlarsen/MockObject
License MIT
Platforms ios 11.0, requires ARC
Authors

This was created to use in unit tests for apps utilizing CoreBluetooth or any other Apple framework that doesn’t allow you to instantiate framework elements. (Ex. CBPeripheral)

Install

In your podfile add

pod 'MockObject'

Usage

You can create an instance of any class by writing MockObject.createInstance(ofClass: "YOUR_CLASS"). This object will return as Any? so you need to tell the compiler what it is and assign required values, but you’ll be able to use it for anything that requires an instance of that class. It’s useful for unit tests, but NEVER USE THIS IN PRODUCTION CODE

Ex:

guard let peri = MockObject.createInstance(ofClass: String(describing: CBPeripheral.self)) as? CBPeripheral else {
  XCTFail()
  return
}

peri.setValue(UUID(), forKey: "identifier")
peri.addObserver(peri, forKeyPath: "delegate", options: .new, context: nil)

Latest podspec

{
    "name": "MockObject",
    "version": "0.1.2",
    "summary": "Framework for creating mock objects of iOS framework elements that are unable to be instantiated.  Ex: CBPeripheral",
    "description": "Mock any class, created to instantiate framework classes for unit testing an app that uses CoreBluetooth.  Ex: CBPeripheral",
    "homepage": "https://github.com/cjlarsen/MockObject",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Chris Larsen": "[email protected]"
    },
    "social_media_url": "https://twitter.com/ChrsJLrsn",
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/cjlarsen/MockObject.git",
        "tag": "0.1.2"
    },
    "source_files": "MockObject/**/*.{h,m}",
    "public_header_files": "MockObject/**/*.h",
    "requires_arc": true
}

Pin It on Pinterest

Share This