What is Mockit?

Mockit is a Tasty mocking framework for unit tests in Swift 4.0. It’s at an early stage of development, but its current features are almost completely usable.

Mockit is a mocking framework that tastes brilliant. It lets you write beautiful tests with a clean & simple API. Tests written using Mockit are very readable and they produce clean verification errors. It’s inspired by the famous mocking framework for Java – Mockito.

Features:

  • Stubbing. Mockit lets you stub a method and then perform any of 3 actions (thenReturn, thenDo, thenAnswer) individually or in any order via chaining;
  • Mocking. You can create a subclass extending the Mock protocol to mock required methods;
  • Call Verification. You can verify method calls using one of 8 supported modes (Once, AtLeastOnce, AtMostOnce, Times, AtLeastTimes, AtMostTimes, Never and Only);
  • Arguments of specific call. Mockit allows you to obtain the arguments of a specific method call to use custom assertions on them;
  • Helpful messages. If method verification fails or something goes wrong, Mockit provides readable messages that describes the issue;
  • Default Type matchers. Out of the box, Mockit can match the following types:

-String / String?

-Bool / Bool?

-Int / Int?

-Double / Double?

-Float / Float?

-Array / Array? of the above primitive types

-Dictionary / Dictionary? of the above primitive types

Given that Swift does not have reflection, Mockit cannot magically match your custom types, so you need to subclass TypeMatcher protocol to write your one custom type matcher. For an example, see the Basic Usage section below.

Overview

  • Pricing: Free
  • Resource Link: https://github.com/sabirvirtuoso/Mockit
  • Resource Maker: Syed Sabir Salman-Al-Musawi
  • Mobile Platform Destination: iOS Apps
  • Mobile Platform Support: Native iOS
  • Programming Languages: Swift
  • CocoaPods: Mockit