Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/merindorium/guava
A Swift test double library. Guava - looks like an apple but it's not.
https://github.com/merindorium/guava
fake library spy stub swift test-doubles unit-testing
Last synced: about 2 months ago
JSON representation
A Swift test double library. Guava - looks like an apple but it's not.
- Host: GitHub
- URL: https://github.com/merindorium/guava
- Owner: merindorium
- License: mit
- Created: 2019-08-21T19:33:24.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-10-24T15:48:29.000Z (3 months ago)
- Last Synced: 2024-10-25T21:36:24.781Z (3 months ago)
- Topics: fake, library, spy, stub, swift, test-doubles, unit-testing
- Language: Swift
- Homepage:
- Size: 81.1 KB
- Stars: 11
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Guava
Guava helps you to make your unit tests more flexible. It allows you to replace parts of your system under test with a test double objects.
----
![build](https://github.com/merindorium/Guava/workflows/build/badge.svg?branch=master)
![Swift 5.x](https://img.shields.io/badge/Swift-5.x-orange.svg)
![platform](https://img.shields.io/badge/platform-ios%20%7C%20osx%20%7C%20linux-lightgray.svg)
![version](https://img.shields.io/github/v/tag/merindorium/guava?label=version)Table of Contents
=================- [Usage](#usage)
- [Documentation](#documentation)
- [Installation](#installation)# Features
Guava provides several types of test doubles:
- Stub
- Spy
- Fake# Usage
```swift
import Guava
import XCTestprotocol Calculator {
func multiply(_ lhs: Int, _ rhs: Int) -> Int
}final class CalculatorTestDouble: Calculator {
let multiplyMethod = TestDoubleFactory()
func multiply(_ lhs: Int, _ rhs: Int) -> Int {
return multiplyMethod.invoke(arguments: [lhs, rhs])
}
}final class CalculatorTestCase: XCTestCase {
func testMultiply() {
let stubValue = 5
let calculatorTestDouble = CalculatorTestDouble()calculatorTestDouble.multiplyMethod.stub(stubValue)
let result = calculatorTestDouble.multiply(3, 3)
XCTAssertEqual(result, stubValue)
}
}
```# Documentation
See [Documentation](Documentation) section.
# Installation
## Swift Package Manager
To use `Guava` with SPM update your `Package.swift`.
```swift
import PackageDescriptionlet package = Package(
name: "ExampleProject",
dependencies: [
.package(url: "https://github.com/merindorium/Guava.git", from: "v1.2.0")
],
...
)```