Swift Mock Generator for AppCode

Compatible with AppCode
Feb 09, 2018
1 107
Automatically generate your mocks in one action.
  • Generates mock conforming to one or many protocols.
  • Generates mock conforming to a class.
  • Captures invocation status of methods.
  • Captures invocation status of properties.
  • Records multiple invocations of methods.
  • Records multiple invocations of properties.
  • Captures invoked method parameters.
  • Records multiple invocations of method parameters.
  • Stubs values for your mocks to return.
  • Stubs a default value for return values where possible.
  • Automatically calls closure parameters with stubbed values.
  • Generates convenience initializers requiring no parameters.
  • Supports initializers with arguments.
  • Supports failable initialzers.
  • Supports required initialzers.
  • Stub an error for your mock method to throw.
  • Supports throwing initializers.
  • Supports throwing closures.
  • Avoids naming clashes from overloaded methods.
  • Generates generic mocks from protocols with associated types.
  • Supports parameter type-annotation attributes and `inout`.
  • Respects the mock scope and generates `public` and `open` methods and properties.
  • Generate mock inheriting from items in 3rd party frameworks.
class MockDataStore: DataStore {
class MockDataStore: DataStore {

    var invokedSave = false
    var invokedSaveCount = 0
    var invokedSaveParameters: (data: Data, file: URL)?
    var invokedSaveParametersList = [(data: Data, file: URL)]()
    var stubbedSaveError: Error?
    var stubbedSaveResult: Bool! = false

    func save(_ data: Data, to file: URL) throws -> Bool {
        invokedSave = true
        invokedSaveCount += 1
        invokedSaveParameters = (data, file)
        invokedSaveParametersList.append((data, file))
        if let error = stubbedSaveError {
            throw error
        return stubbedSaveResult

Download plugin

Recent change notes

  • Resolves typealiases that reference another typealias correctly.
  • Supports initialisers declared in protocols.