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 – Built for High-Performance Time Series Workloads
InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. 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.

  2. InfluxDB

    InfluxDB – Built for High-Performance Time Series Workloads. InfluxDB 3 OSS is now GA. Transform, enrich, and act on time series data directly in the database. Automate critical tasks and eliminate the need to move data externally. Download now.

    InfluxDB logo
  3. 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.

  4. 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:

  5. 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

Did you know that Swift is
the 15th most popular programming language
based on number of references?