swift-fakes

0.1.2

Test Doubles for Swift
Quick/swift-fakes

What's New

v0.1.2

2024-05-26T23:01:34Z

What's Changed

  • Provide default initializers for Spy when throwing any Swift.Error by @younata in #18

Full Changelog: v0.1.1...v0.1.2

swift-fakes

Swift Fakes aims to improve the testability of Swift by providing standardized test doubles.

Test doubles are objects used to replace production objects for testing purposes.

Installation

To use the Fakes library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:

.package(url: "https://github.com/Quick/swift-fakes", from: "0.1.1"),

Include "Fakes" as a dependency for your test target:

.testTarget(name: "<target>", dependencies: [
    .product(name: "Fakes", package: "swift-fakes"),
]),

Motivation

When writing tests, we want to write one thing at a time. This is best done by providing fakes or non-production test-controllable objects to the thing being tested (the subject). This is typically done by writing fakes that implement the protocols that the subject depends on. Swift Fakes aims to make writing Fakes as easy as possible.

Contents

For the time being, Swift Fakes only offers the Spy object. Spys are a kind of test double that record calls to the object, and return a preset response.

Spy

Spies are meant to be used in Fake objects to record arguments to a call, and return pre-stubbed responses.

See the documentation.

Source Stability

Swift Fakes is currently available as an Alpha. By 1.0, we aim to have it source stable and following Semantic Versioning.

Description

  • Swift Tools 5.9.0
View More Packages from this Author

Dependencies

Last updated: Mon Nov 18 2024 11:37:59 GMT-1000 (Hawaii-Aleutian Standard Time)