Swiftpack.co -  Package - mimus-swift/Mimus
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
mimus-swift/Mimus
Swift Mocking Library
.package(url: "https://github.com/mimus-swift/Mimus.git", from: "2.0.0")

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

Cocoapods

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

pod "Mimus"

Carthage

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

github "Airhelp/Mimus"

and then link it with your test target.

Swift Package Manager

Mimus is available through Swift Package Manager.

  • When added as a package dependency:
dependencies: [
        .package(
            url: "https://github.com/AirHelp/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.

Authors

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

Logo Design by Arkadiusz Lipiarz @arek_lipiarz, arkadiusz.lipiarz@airhelp.com

License

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

GitHub

link
Stars: 100
Last commit: 1 week ago

Release Notes

The Great Rename
1 week ago
  • BREAKING MockEquatable has been renamed to Matcher to more closely express functionality provided (there is a typealias for backwards compatibility but it might still be breaking in some cases)
  • BREAKING Mock.storage type has been changed from [RecordedCall] to Storage to better support future features (like e.g. the recording of return values)
  • BREAKING Calling verify will now reset previously recorded values
  • Added option to record values that should be returned for specific invocations
  • Added option to provide a custom failure message for a matcher

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco