Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/quick/swift-fakes
Test Doubles for Swift
https://github.com/quick/swift-fakes
bdd fakes ios mocks spies stubs swift testing
Last synced: 2 months ago
JSON representation
Test Doubles for Swift
- Host: GitHub
- URL: https://github.com/quick/swift-fakes
- Owner: Quick
- License: apache-2.0
- Created: 2024-03-29T01:15:31.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-04-24T05:20:24.000Z (8 months ago)
- Last Synced: 2024-05-09T11:28:39.435Z (8 months ago)
- Topics: bdd, fakes, ios, mocks, spies, stubs, swift, testing
- Language: Swift
- Homepage: https://quick.github.io/swift-fakes/documentation/fakes
- Size: 437 KB
- Stars: 20
- Watchers: 4
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- Funding: .github/funding.yml
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# swift-fakes
Swift Fakes aims to improve the testability of Swift by providing standardized
[test doubles](https://martinfowler.com/bliki/TestDouble.html).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:```swift
.package(url: "https://github.com/Quick/swift-fakes", from: "0.1.1"),
```Include `"Fakes"` as a dependency for your test target:
```swift
.testTarget(name: "", 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](https://github.com/testdouble/contributing-tests/wiki/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. `Spy`s 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](https://quick.github.io/swift-fakes/documentation/fakes).
## Source Stability
Swift Fakes is currently available as an Alpha. By 1.0, we aim to have it source
stable and following Semantic Versioning.