Writing unit tests with mocked dependencies in Swift

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • MockSwift

    MockSwift is a Mock library written in Swift.

    Instead of creating our own test version of a class implementing the ApiClientProtocol, we'll use a mocking package to do the heavy lifting for us. There are multiple mocking packages for Swift, but I'll be using MockSwift here. Setting it up requires some work, since it has to work around the limitations of Swift.

  • Insanity

    Meta-programming for Swift, stop writing boilerplate code.

    To set up MockSwift, make sure you have Sourcery and the package installed. Then, create a script called gen-mocks.sh with the following content (updating the paths if required):

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

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