Swift Mock Generator for AppCode

Compatible with AppCode
Nov 20, 2017
815
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.
  • 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.
Before:
class MockDataStore: DataStore {
  
}
      
After:
class MockDataStore: DataStore {

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

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

Download plugin

Recent change notes

Supports 2017.3 Generate a mock inheriting from a class