Skip to content

mimus-swift/Mimus

Repository files navigation

Mimus

Version Platform Carthage compatible CocoaPods compatible License MIT Public Yes Build Status

Mimus is a bird genus in the family Mimidae. It contains the typical mockingbirds.

Mimus is a Swift mocking library, aiming to reduce boilerplate code required for building mocks in Swift. It's been battle tested at AirHelp and Toptal where it's being used extensively across test suites.

Main features

  • Pure Swift
  • Protocol-oriented implementation
  • Integrated with XCTest
  • Support for verification of basic types and collections (including optionals)
  • Support for writing custom matchers
  • Detailed failure reporting
  • Unit-tested

Usage

A Mimus mock can be created by declaring a class that conforms to your custom protocol and Mimus Mock type:

class FakeAuthenticationManager: AuthenticationManager, Mock {

    var storage = Mimus.Storage()

    func beginAuthentication(with email: String, password: String) {
        recordCall(withIdentifier: "BeginAuthentication", arguments: [email, password])
    }
}

Afterwards you can verify whether specific call was received:

let fakeLoginAuthenticationManager = FakeAuthenticationManager()

(...)

fakeLoginAuthenticationManager.verifyCall(withIdentifier: "BeginAuthentication",
        arguments: [mEqual("Fixture Email"), mEqual("Fixture Password")])

You can find more on the basic usage here.

For detailed usage refer to documentation folder.

Installation

Swift Package Manager

Mimus is available through Swift Package Manager.

When added as a package dependency

dependencies: [
        .package(
            url: "https://github.com/mimus-swift/Mimus.git",
            from: "1.1.4"
        )
    ]

When added as an Application dependency:

To add a package dependency to your Xcode project, select File > Swift Packages > Add Package Dependency and enter its repository URL.

You can also navigate to your target’s General pane, and in the “Frameworks, Libraries, and Embedded Content” section, click the + button. In the “Choose frameworks and libraries to add” dialog, select Add Other, and choose Add Package Dependency.

Carthage

You can also use Carthage for installing Mimus. Simply add it to your Cartfile:

github "mimus-swift/Mimus"

and then link it with your test target.

Cocoapods - 🚨 DEPRECATED 🚨

Mimus is available through CocoaPods. To install it, simply add the following line to your Podfile against your test target:

pod "Mimus"

Note that starting with 2.1.0 Mimus will not be distributed via Cocoapods - we're moving to Swift Package Manager and we recommend everyone to do the same. You can still use Cocoapods with latest versions by pinning to a specific tag.

Authors

Mimus is an AirHelp open source project, designed and implemented by

Logo Design by Arkadiusz Lipiarz @arek_lipiarz, [email protected]

License

Mimus is available under the MIT license. See the LICENSE file for more info.