Swift Mocking Tools. To Use, or Not to Use, That Is the Question

This page summarizes the projects mentioned and recommended in the original post on /r/u_Evolvice

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • OCMockito

    Mockito for Objective-C: creation, verification and stubbing of mock objects

  • Everything would be smooth and easy, except that Swift is not Objective-C. Supplying test doubles is incredibly easy in Objective-C, where the central mechanism is messages. You could send any message to any object. In case you had previous experience mocking on Objective-C using OCMock or OCMockito — forget it.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Cuckoo

    Boilerplate-free mocking framework for Swift! (by Brightify)

  • Additional setup: The cuckoo installation process requires adding a new run script into your test target build phases. Include the absolute path to each file and the framework that will generate mocks in this script. Import the generated file into the project once, and then re-generate it to keep it up to date. Class name starts from the word ‘Mock’ — each test double you can use as mock, stub, or spy.

  • SwiftyMocky

    Framework for automatic mock generation. Adds a set of handy methods, simplifying testing. One of the best and most complete solutions, including generics support and much more.

  • Additional setup: SwiftyMocky has a 2 step installation. First, set up SwiftyMocky CLI on your working machine. Second, add it to the project’s test target via one of the 3 options listed above. Open Terminal in your project root folder and execute the following commands one by one:

  • SwiftMockGeneratorForXcode

    An Xcode extension (plugin) to generate Swift test doubles automatically.

  • Spoiler! It’s not a library but an Xcode plugin that helps solve the same problem — generating test doubles. SwiftMockGeneratorForXcode is an exception in this list of frameworks. Instead of being integrated into the project, this generator can only be added as an extension to Xcode. Also, you won’t have any custom verifiers or matchers, do all assertions using the XCTest framework.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Tests Everywhere - Swift

    2 projects | dev.to | 12 Dec 2023
  • XCTest different behavior locally vs Xcode Cloud

    1 project | /r/swift | 8 Dec 2023
  • Looking for Mocking Framework

    2 projects | /r/swift | 8 May 2023
  • iOS unit test mocking using SwiftyMocky

    1 project | dev.to | 27 Nov 2022
  • Writing unit tests with mocked dependencies in Swift

    2 projects | dev.to | 9 Nov 2022