From 8e8135e5e82045315ecaa24dda897368c5cfc450 Mon Sep 17 00:00:00 2001
From: Andrew Chang
Date: Thu, 30 Dec 2021 19:13:39 -1000
Subject: [PATCH 01/20] Format header documentation with DocC markdown
---
.../Matching/ArgumentCaptor.swift | 12 +-
.../Matching/ArgumentPosition.swift | 168 +++++----
.../Matching/CollectionMatchers.swift | 264 ++++++++------
.../Matching/CountMatcher.swift | 110 ++++--
.../Matching/NonEscapingType.swift | 30 +-
.../Matching/WildcardMatchers.swift | 345 ++++++++++--------
.../Mocking/Mocking.swift | 182 +++++----
.../Objective-C/Bridge/include/MKBTestUtils.h | 16 +-
.../Stubbing/DefaultValues.swift | 68 ++--
.../Stubbing/DynamicStubbingManager.swift | 236 +++++++-----
.../Stubbing/InvocationForwarding.swift | 328 ++++++++++-------
.../Stubbing/PropertyProviders.swift | 10 +-
.../Stubbing/SequenceProviders.swift | 96 ++---
.../Stubbing/Stubbing+ObjC.swift | 236 +++++++-----
.../Stubbing/Stubbing.swift | 332 ++++++++++-------
.../Stubbing/ValueProvider.swift | 142 +++----
.../Verification/AsyncVerification.swift | 20 +-
.../Verification/OrderedVerification.swift | 136 +++----
.../Verification/Verification.swift | 54 +--
19 files changed, 1591 insertions(+), 1194 deletions(-)
diff --git a/Sources/MockingbirdFramework/Matching/ArgumentCaptor.swift b/Sources/MockingbirdFramework/Matching/ArgumentCaptor.swift
index 5d8923b2..ec7590bf 100644
--- a/Sources/MockingbirdFramework/Matching/ArgumentCaptor.swift
+++ b/Sources/MockingbirdFramework/Matching/ArgumentCaptor.swift
@@ -12,12 +12,14 @@ import Foundation
/// An argument captor extracts received argument values which can be used in other parts of the
/// test.
///
-/// let bird = mock(Bird.self)
-/// bird.name = "Ryan"
+/// ```swift
+/// let bird = mock(Bird.self)
+/// bird.name = "Ryan"
///
-/// let nameCaptor = ArgumentCaptor()
-/// verify(bird.name = any()).wasCalled()
-/// print(nameCaptor.value) // Prints "Ryan"
+/// let nameCaptor = ArgumentCaptor()
+/// verify(bird.name = any()).wasCalled()
+/// print(nameCaptor.value) // Prints "Ryan"
+/// ```
public class ArgumentCaptor: ArgumentMatcher {
final class WeakBox {
weak var value: A?
diff --git a/Sources/MockingbirdFramework/Matching/ArgumentPosition.swift b/Sources/MockingbirdFramework/Matching/ArgumentPosition.swift
index 8950cdaa..efd15c1d 100644
--- a/Sources/MockingbirdFramework/Matching/ArgumentPosition.swift
+++ b/Sources/MockingbirdFramework/Matching/ArgumentPosition.swift
@@ -12,23 +12,27 @@ import Foundation
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
@@ -52,23 +56,27 @@ public func arg(_ matcher: @autoclosure () -> T, at position: Int) -> T {
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
@@ -84,23 +92,27 @@ public func firstArg(_ matcher: @autoclosure () -> T) -> T {
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
@@ -116,23 +128,27 @@ public func secondArg(_ matcher: @autoclosure () -> T) -> T {
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
@@ -148,23 +164,27 @@ public func thirdArg(_ matcher: @autoclosure () -> T) -> T {
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
@@ -180,23 +200,27 @@ public func fourthArg(_ matcher: @autoclosure () -> T) -> T {
/// You must provide an explicit argument position when using argument matchers on an Objective-C
/// method with multiple value type parameters.
///
-/// @objc class Bird: NSObject {
-/// @objc dynamic func chirp(volume: Int, duration: Int) {}
-/// }
+/// ```swift
+/// @objc class Bird: NSObject {
+/// @objc dynamic func chirp(volume: Int, duration: Int) {}
+/// }
///
-/// given(bird.chirp(volume: firstArg(any()),
-/// duration: secondArg(any()))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// given(bird.chirp(volume: firstArg(any()),
+/// duration: secondArg(any()))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
///
-/// bird.chirp(42, 9001) // Prints 42, 9001
+/// bird.chirp(42, 9001) // Prints 42, 9001
+/// ```
///
/// This is equivalent to the verbose form of declaring an argument position.
///
-/// given(bird.chirp(volume: arg(any(), at: 0),
-/// duration: arg(any(), at: 1))).will {
-/// print($0 as! Int, $1 as! Int)
-/// }
+/// ```swift
+/// given(bird.chirp(volume: arg(any(), at: 0),
+/// duration: arg(any(), at: 1))).will {
+/// print($0 as! Int, $1 as! Int)
+/// }
+/// ```
///
/// - Note: This helper has no effect on argument matchers passed to statically generated Swift
/// mocks or to object parameter types.
diff --git a/Sources/MockingbirdFramework/Matching/CollectionMatchers.swift b/Sources/MockingbirdFramework/Matching/CollectionMatchers.swift
index dc56af73..376399ea 100644
--- a/Sources/MockingbirdFramework/Matching/CollectionMatchers.swift
+++ b/Sources/MockingbirdFramework/Matching/CollectionMatchers.swift
@@ -13,30 +13,34 @@ import Foundation
/// Use the argument matcher `any(containing:)` to match collections that contain all specified
/// values.
///
-/// protocol Bird {
-/// func send(_ messages: [String])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [String])
+/// }
///
-/// given(bird.send(any(containing: "Hi", "Hello")))
-/// .will { print($0) }
+/// given(bird.send(any(containing: "Hi", "Hello")))
+/// .will { print($0) }
///
-/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
-/// bird.send(["Hi", "Bye"]) // Error: Missing stubbed implementation
-/// bird.send(["Bye"]) // Error: Missing stubbed implementation
+/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
+/// bird.send(["Hi", "Bye"]) // Error: Missing stubbed implementation
+/// bird.send(["Bye"]) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ messages: [T]) // Overloaded generically
-/// func send(_ messages: [String]) // Overloaded explicitly
-/// func send(_ messages: [Data])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [T]) // Overloaded generically
+/// func send(_ messages: [String]) // Overloaded explicitly
+/// func send(_ messages: [Data])
+/// }
///
-/// given(bird.send(any([String].self, containing: ["Hi", "Hello"])))
-/// .will { print($0) }
+/// given(bird.send(any([String].self, containing: ["Hi", "Hello"])))
+/// .will { print($0) }
///
-/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
-/// bird.send([Data([1]), Data(2)]) // Error: Missing stubbed implementation
+/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
+/// bird.send([Data([1]), Data(2)]) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -61,47 +65,51 @@ public func any(_ type: T.Type = T.self, containing values: T.Ele
/// Use the argument matcher `any(containing:)` to match dictionaries that contain all specified
/// values.
///
-/// protocol Bird {
-/// func send(_ messages: [UUID: String])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [UUID: String])
+/// }
///
-/// given(bird.send(any(containing: "Hi", "Hello")))
-/// .will { print($0) }
+/// given(bird.send(any(containing: "Hi", "Hello")))
+/// .will { print($0) }
///
-/// bird.send([
-/// UUID(): "Hi",
-/// UUID(): "Hello",
-/// ]) // Prints ["Hi", "Hello"]
+/// bird.send([
+/// UUID(): "Hi",
+/// UUID(): "Hello",
+/// ]) // Prints ["Hi", "Hello"]
///
-/// bird.send([
-/// UUID(): "Hi",
-/// UUID(): "Bye",
-/// ]) // Error: Missing stubbed implementation
+/// bird.send([
+/// UUID(): "Hi",
+/// UUID(): "Bye",
+/// ]) // Error: Missing stubbed implementation
///
-/// bird.send([
-/// UUID(): "Bye",
-/// ]) // Error: Missing stubbed implementation
+/// bird.send([
+/// UUID(): "Bye",
+/// ]) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ messages: [UUID: T]) // Overloaded generically
-/// func send(_ messages: [UUID: String]) // Overloaded explicitly
-/// func send(_ messages: [UUID: Data])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [UUID: T]) // Overloaded generically
+/// func send(_ messages: [UUID: String]) // Overloaded explicitly
+/// func send(_ messages: [UUID: Data])
+/// }
///
-/// given(bird.send(any([UUID: String].self, containing: "Hi", "Hello")))
-/// .will { print($0) }
+/// given(bird.send(any([UUID: String].self, containing: "Hi", "Hello")))
+/// .will { print($0) }
///
-/// bird.send([
-/// UUID(): "Hi",
-/// UUID(): "Hello",
-/// ]) // Prints ["Hi", "Hello"]
+/// bird.send([
+/// UUID(): "Hi",
+/// UUID(): "Hello",
+/// ]) // Prints ["Hi", "Hello"]
///
-/// bird.send([
-/// UUID(): Data([1]),
-/// UUID(): Data([2]),
-/// ]) // Error: Missing stubbed implementation
+/// bird.send([
+/// UUID(): Data([1]),
+/// UUID(): Data([2]),
+/// ]) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -126,47 +134,51 @@ public func any(_ type: Dictionary.Type = Dictionary.self,
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
/// Use the argument matcher `any(keys:)` to match dictionaries that contain all specified keys.
///
-/// protocol Bird {
-/// func send(_ messages: [UUID: String])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [UUID: String])
+/// }
///
-/// let messageId1 = UUID()
-/// let messageId2 = UUID()
-/// given(bird.send(any(keys: messageId1, messageId2)))
-/// .will { print($0) }
+/// let messageId1 = UUID()
+/// let messageId2 = UUID()
+/// given(bird.send(any(keys: messageId1, messageId2)))
+/// .will { print($0) }
///
-/// bird.send([
-/// messageId1: "Hi",
-/// messageId2: "Hello",
-/// ]) // Prints ["Hi", "Hello"]
+/// bird.send([
+/// messageId1: "Hi",
+/// messageId2: "Hello",
+/// ]) // Prints ["Hi", "Hello"]
///
-/// bird.send([
-/// UUID(): "Hi",
-/// UUID(): "Hello",
-/// ]) // Error: Missing stubbed implementation
+/// bird.send([
+/// UUID(): "Hi",
+/// UUID(): "Hello",
+/// ]) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ messages: [UUID: T]) // Overloaded generically
-/// func send(_ messages: [UUID: String]) // Overloaded explicitly
-/// func send(_ messages: [UUID: Data])
-/// }
-///
-/// let messageId1 = UUID()
-/// let messageId2 = UUID()
-/// given(bird.send(any([UUID: String].self, keys: messageId1, messageId2)))
-/// .will { print($0) }
-///
-/// bird.send([
-/// messageId1: "Hi",
-/// messageId2: "Hello",
-/// ]) // Prints ["Hi", "Hello"]
-///
-/// bird.send([
-/// messageId1: Data([1]),
-/// messageId2: Data([2]),
-/// ]) // Error: Missing stubbed implementation
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [UUID: T]) // Overloaded generically
+/// func send(_ messages: [UUID: String]) // Overloaded explicitly
+/// func send(_ messages: [UUID: Data])
+/// }
+///
+/// let messageId1 = UUID()
+/// let messageId2 = UUID()
+/// given(bird.send(any([UUID: String].self, keys: messageId1, messageId2)))
+/// .will { print($0) }
+///
+/// bird.send([
+/// messageId1: "Hi",
+/// messageId2: "Hello",
+/// ]) // Prints ["Hi", "Hello"]
+///
+/// bird.send([
+/// messageId1: Data([1]),
+/// messageId2: Data([2]),
+/// ]) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -191,28 +203,32 @@ public func any(_ type: Dictionary.Type = Dictionary.self,
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
/// Use the argument matcher `any(count:)` to match collections with a specific number of elements.
///
-/// protocol Bird {
-/// func send(_ messages: [String])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [String])
+/// }
///
-/// given(bird.send(any(count: 2))).will { print($0) }
+/// given(bird.send(any(count: 2))).will { print($0) }
///
-/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
-/// bird.send(["Hi"]) // Error: Missing stubbed implementation
+/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
+/// bird.send(["Hi"]) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ messages: [T]) // Overloaded generically
-/// func send(_ messages: [String]) // Overloaded explicitly
-/// func send(_ messages: [Data])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [T]) // Overloaded generically
+/// func send(_ messages: [String]) // Overloaded explicitly
+/// func send(_ messages: [Data])
+/// }
///
-/// given(bird.send(any([String].self, count: 2)))
-/// .will { print($0) }
+/// given(bird.send(any([String].self, count: 2)))
+/// .will { print($0) }
///
-/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
-/// bird.send([Data([1]), Data([2])]) // Error: Missing stubbed implementation
+/// bird.send(["Hi", "Hello"]) // Prints ["Hi", "Hello"]
+/// bird.send([Data([1]), Data([2])]) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -233,28 +249,32 @@ public func any(_ type: T.Type = T.self, count countMatcher: Coun
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
/// Use the argument matcher `notEmpty` to match collections with one or more elements.
///
-/// protocol Bird {
-/// func send(_ messages: [String])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [String])
+/// }
///
-/// given(bird.send(any(count: 2))).will { print($0) }
+/// given(bird.send(any(count: 2))).will { print($0) }
///
-/// bird.send(["Hi"]) // Prints ["Hi"]
-/// bird.send([]) // Error: Missing stubbed implementation
+/// bird.send(["Hi"]) // Prints ["Hi"]
+/// bird.send([]) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ messages: [T]) // Overloaded generically
-/// func send(_ messages: [String]) // Overloaded explicitly
-/// func send(_ messages: [Data])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ messages: [T]) // Overloaded generically
+/// func send(_ messages: [String]) // Overloaded explicitly
+/// func send(_ messages: [Data])
+/// }
///
-/// given(bird.send(notEmpty([String].self)))
-/// .will { print($0) }
+/// given(bird.send(notEmpty([String].self)))
+/// .will { print($0) }
///
-/// bird.send(["Hi"]) // Prints ["Hi"]
-/// bird.send([Data([1])]) // Error: Missing stubbed implementation
+/// bird.send(["Hi"]) // Prints ["Hi"]
+/// bird.send([Data([1])]) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter type: The parameter type used to disambiguate overloaded methods.
public func notEmpty(_ type: T.Type = T.self) -> T {
@@ -267,16 +287,18 @@ public func notEmpty(_ type: T.Type = T.self) -> T {
///
/// Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
///
-/// protocol Bird {
-/// func canChirp(volume: Double) -> Bool
-/// }
+/// ```swift
+/// protocol Bird {
+/// func canChirp(volume: Double) -> Bool
+/// }
///
-/// given(bird.canChirp(volume: around(42.0, tolerance: 0.1)))
-/// .willReturn(true)
+/// given(bird.canChirp(volume: around(42.0, tolerance: 0.1)))
+/// .willReturn(true)
///
-/// print(bird.canChirp(volume: 42.0)) // Prints "true"
-/// print(bird.canChirp(volume: 42.0999)) // Prints "true"
-/// print(bird.canChirp(volume: 42.1)) // Prints "false"
+/// print(bird.canChirp(volume: 42.0)) // Prints "true"
+/// print(bird.canChirp(volume: 42.0999)) // Prints "true"
+/// print(bird.canChirp(volume: 42.1)) // Prints "false"
+/// ```
///
/// - Parameters:
/// - value: The expected value.
diff --git a/Sources/MockingbirdFramework/Matching/CountMatcher.swift b/Sources/MockingbirdFramework/Matching/CountMatcher.swift
index 06776094..b5f21d80 100644
--- a/Sources/MockingbirdFramework/Matching/CountMatcher.swift
+++ b/Sources/MockingbirdFramework/Matching/CountMatcher.swift
@@ -45,16 +45,20 @@ public let twice: Int = 2
/// The `exactly` count matcher can be used to verify that the actual number of invocations received
/// by a mock equals the expected number of invocations.
///
-/// // Given two invocations (n = 2)
-/// bird.fly()
-/// bird.fly()
+/// ```swift
+/// // Given two invocations (n = 2)
+/// bird.fly()
+/// bird.fly()
///
-/// verify(bird.fly()).wasCalled(exactly(1)) // Fails (n ≠ 1)
-/// verify(bird.fly()).wasCalled(exactly(2)) // Passes
+/// verify(bird.fly()).wasCalled(exactly(1)) // Fails (n ≠ 1)
+/// verify(bird.fly()).wasCalled(exactly(2)) // Passes
+/// ```
///
/// You can combine count matchers with adverbial counts for improved readability.
///
-/// verify(bird.fly()).wasCalled(exactly(once))
+/// ```swift
+/// verify(bird.fly()).wasCalled(exactly(once))
+/// ```
///
/// - Parameter times: An exact integer count.
/// - Returns: A count matcher.
@@ -67,17 +71,21 @@ public func exactly(_ times: Int) -> CountMatcher {
/// The `atLeast` count matcher can be used to verify that the actual number of invocations received
/// by a mock is greater than or equal to the expected number of invocations.
///
-/// // Given two invocations (n = 2)
-/// bird.fly()
-/// bird.fly()
+/// ```swift
+/// // Given two invocations (n = 2)
+/// bird.fly()
+/// bird.fly()
///
-/// verify(bird.fly()).wasCalled(atLeast(1)) // Passes
-/// verify(bird.fly()).wasCalled(atLeast(2)) // Passes
-/// verify(bird.fly()).wasCalled(atLeast(3)) // Fails (n < 3)
+/// verify(bird.fly()).wasCalled(atLeast(1)) // Passes
+/// verify(bird.fly()).wasCalled(atLeast(2)) // Passes
+/// verify(bird.fly()).wasCalled(atLeast(3)) // Fails (n < 3)
+/// ```
///
/// You can combine count matchers with adverbial counts for improved readability.
///
-/// verify(bird.fly()).wasCalled(atLeast(once))
+/// ```swift
+/// verify(bird.fly()).wasCalled(atLeast(once))
+/// ```
///
/// - Parameter times: An inclusive lower bound.
/// - Returns: A count matcher.
@@ -90,17 +98,21 @@ public func atLeast(_ times: Int) -> CountMatcher {
/// The `atMost` count matcher can be used to verify that the actual number of invocations received
/// by a mock is less than or equal to the expected number of invocations.
///
-/// // Given two invocations (n = 2)
-/// bird.fly()
-/// bird.fly()
+/// ```swift
+/// // Given two invocations (n = 2)
+/// bird.fly()
+/// bird.fly()
///
-/// verify(bird.fly()).wasCalled(atMost(1)) // Fails (n > 1)
-/// verify(bird.fly()).wasCalled(atMost(2)) // Passes
-/// verify(bird.fly()).wasCalled(atMost(3)) // Passes
+/// verify(bird.fly()).wasCalled(atMost(1)) // Fails (n > 1)
+/// verify(bird.fly()).wasCalled(atMost(2)) // Passes
+/// verify(bird.fly()).wasCalled(atMost(3)) // Passes
+/// ```
///
/// You can combine count matchers with adverbial counts for improved readability.
///
-/// verify(bird.fly()).wasCalled(atMost(once))
+/// ```swift
+/// verify(bird.fly()).wasCalled(atMost(once))
+/// ```
///
/// - Parameter times: An inclusive upper bound.
/// - Returns: A count matcher.
@@ -113,16 +125,20 @@ public func atMost(_ times: Int) -> CountMatcher {
/// The `between` count matcher can be used to verify that the actual number of invocations received
/// by a mock is within an inclusive range of expected invocations.
///
-/// // Given two invocations (n = 2)
-/// bird.fly()
-/// bird.fly()
+/// ```swift
+/// // Given two invocations (n = 2)
+/// bird.fly()
+/// bird.fly()
///
-/// verify(bird.fly()).wasCalled(between(1...2)) // Passes
-/// verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
+/// verify(bird.fly()).wasCalled(between(1...2)) // Passes
+/// verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
+/// ```
///
/// You can combine count matchers with adverbial counts for improved readability.
///
-/// verify(bird.fly()).wasCalled(between(once...twice))
+/// ```swift
+/// verify(bird.fly()).wasCalled(between(once...twice))
+/// ```
///
/// - Parameter range: An closed integer range.
/// - Returns: A count matcher.
@@ -138,8 +154,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
- /// // Checks that n = 1 || n ≥ 42
- /// verify(bird.fly()).wasCalled(exactly(once).or(atLeast(42)))
+ /// ```swift
+ /// // Checks that n = 1 || n ≥ 42
+ /// verify(bird.fly()).wasCalled(exactly(once).or(atLeast(42)))
+ /// ```
///
/// - Parameter countMatcher: Another count matcher to combine.
/// - Returns: A combined count matcher.
@@ -160,8 +178,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
- /// // Checks that n = 1 || n = 2
- /// verify(bird.fly()).wasCalled(exactly(once).or(twice))
+ /// ```swift
+ /// // Checks that n = 1 || n = 2
+ /// verify(bird.fly()).wasCalled(exactly(once).or(twice))
+ /// ```
///
/// - Parameter times: An exact count to combine.
/// - Returns: A combined count matcher.
@@ -172,8 +192,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
- /// // Checks that n = 1 && n ≥ 42
- /// verify(bird.fly()).wasCalled(exactly(once).and(atLeast(42)))
+ /// ```swift
+ /// // Checks that n = 1 && n ≥ 42
+ /// verify(bird.fly()).wasCalled(exactly(once).and(atLeast(42)))
+ /// ```
///
/// - Parameter countMatcher: Another count matcher to combine.
/// - Returns: A combined count matcher.
@@ -194,8 +216,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
- /// // Checks that n ≤ 2 ⊕ n ≥ 1
- /// verify(bird.fly()).wasCalled(atMost(twice).xor(atLeast(once)))
+ /// ```swift
+ /// // Checks that n ≤ 2 ⊕ n ≥ 1
+ /// verify(bird.fly()).wasCalled(atMost(twice).xor(atLeast(once)))
+ /// ```
///
/// - Parameter countMatcher: Another count matcher to combine.
/// - Returns: A combined count matcher.
@@ -216,8 +240,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
- /// // Checks that n ≥ 1 ⊕ n = 2
- /// verify(bird.fly()).wasCalled(atLeast(once).xor(twice))
+ /// ```swift
+ /// // Checks that n ≥ 1 ⊕ n = 2
+ /// verify(bird.fly()).wasCalled(atLeast(once).xor(twice))
+ /// ```
///
/// - Parameter times: An exact count.
/// - Returns: A combined count matcher.
@@ -229,8 +255,10 @@ extension CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
-/// // Checks that n ≠ 1
-/// verify(bird.fly()).wasCalled(not(exactly(once)))
+/// ```swift
+/// // Checks that n ≠ 1
+/// verify(bird.fly()).wasCalled(not(exactly(once)))
+/// ```
///
/// - Parameter countMatcher: A count matcher to negate.
/// - Returns: A negated count matcher.
@@ -248,8 +276,10 @@ public func not(_ countMatcher: CountMatcher) -> CountMatcher {
/// Combined count matchers can be used to perform complex checks on the number of invocations
/// received.
///
-/// // Checks that n ≠ 1
-/// verify(bird.fly()).wasCalled(not(once))
+/// ```swift
+/// // Checks that n ≠ 1
+/// verify(bird.fly()).wasCalled(not(once))
+/// ```
///
/// - Parameter countMatcher: An exact count to negate.
/// - Returns: A negated count matcher.
diff --git a/Sources/MockingbirdFramework/Matching/NonEscapingType.swift b/Sources/MockingbirdFramework/Matching/NonEscapingType.swift
index ee73b7e1..866e186b 100644
--- a/Sources/MockingbirdFramework/Matching/NonEscapingType.swift
+++ b/Sources/MockingbirdFramework/Matching/NonEscapingType.swift
@@ -15,24 +15,28 @@ protocol NonEscapingType {}
/// Non-escaping closures cannot be stored in an `Invocation` so an instance of a
/// `NonEscapingClosure` is stored instead.
///
-/// protocol Bird {
-/// func send(_ message: String, callback: (Result) -> Void)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: String, callback: (Result) -> Void)
+/// }
///
-/// bird.send("Hello", callback: { print($0) })
+/// bird.send("Hello", callback: { print($0) })
///
-/// // Must use a wildcard argument matcher like `any`
-/// verify(bird.send("Hello", callback: any())).wasCalled()
+/// // Must use a wildcard argument matcher like `any`
+/// verify(bird.send("Hello", callback: any())).wasCalled()
+/// ```
///
/// Mark closure parameter types as `@escaping` to capture closures during verification.
///
-/// protocol Bird {
-/// func send(_ message: String, callback: @escaping (Result) -> Void)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: String, callback: @escaping (Result) -> Void)
+/// }
///
-/// bird.send("Hello", callback: { print($0) })
+/// bird.send("Hello", callback: { print($0) })
///
-/// let argumentCaptor = ArgumentCaptor<(Result) -> Void>()
-/// verify(bird.send("Hello", callback: argumentCaptor.matcher)).wasCalled()
-/// argumentCaptor.value?(.success) // Prints Result.success
+/// let argumentCaptor = ArgumentCaptor<(Result) -> Void>()
+/// verify(bird.send("Hello", callback: argumentCaptor.matcher)).wasCalled()
+/// argumentCaptor.value?(.success) // Prints Result.success
+/// ```
public class NonEscapingClosure: NonEscapingType {}
diff --git a/Sources/MockingbirdFramework/Matching/WildcardMatchers.swift b/Sources/MockingbirdFramework/Matching/WildcardMatchers.swift
index 91e493f8..4deab144 100644
--- a/Sources/MockingbirdFramework/Matching/WildcardMatchers.swift
+++ b/Sources/MockingbirdFramework/Matching/WildcardMatchers.swift
@@ -13,24 +13,28 @@ import Foundation
/// Use the wildcard argument matcher `any` as a type safe placeholder for matching any argument
/// value.
///
-/// given(bird.canChirp(volume: any())).willReturn(true)
-/// print(bird.canChirp(volume: 10)) // Prints "true"
-/// verify(bird.canChirp(volume: any())).wasCalled()
+/// ```swift
+/// given(bird.canChirp(volume: any())).willReturn(true)
+/// print(bird.canChirp(volume: 10)) // Prints "true"
+/// verify(bird.canChirp(volume: any())).wasCalled()
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ message: T) // Overloaded generically
-/// func send(_ message: String) // Overloaded explicitly
-/// func send(_ message: Data)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: T) // Overloaded generically
+/// func send(_ message: String) // Overloaded explicitly
+/// func send(_ message: Data)
+/// }
///
-/// given(bird.send(any(String.self))).will { print($0) }
+/// given(bird.send(any(String.self))).will { print($0) }
///
-/// bird.send("Hello") // Prints "Hello"
+/// bird.send("Hello") // Prints "Hello"
///
-/// verify(bird.send(any(String.self))).wasCalled()
-/// verify(bird.send(any(Data.self))).wasNeverCalled()
+/// verify(bird.send(any(String.self))).wasCalled()
+/// verify(bird.send(any(Data.self))).wasNeverCalled()
+/// ```
///
/// - Parameter type: The parameter type used to disambiguate overloaded methods.
public func any(_ type: T.Type = T.self) -> T {
@@ -49,30 +53,34 @@ public func any(_ type: T.Type = T.self) -> T {
/// Use the wildcard argument matcher `any` as a type safe placeholder for matching any argument
/// value.
///
-/// // Protocol referencing Obj-C object types
-/// protocol Bird {
-/// func canChirp(volume: NSNumber) -> Bool
-/// }
+/// ```swift
+/// // Protocol referencing Obj-C object types
+/// protocol Bird {
+/// func canChirp(volume: NSNumber) -> Bool
+/// }
///
-/// given(bird.canChirp(volume: any())).willReturn(true)
-/// print(bird.canChirp(volume: 10)) // Prints "true"
-/// verify(bird.canChirp(volume: any())).wasCalled()
+/// given(bird.canChirp(volume: any())).willReturn(true)
+/// print(bird.canChirp(volume: 10)) // Prints "true"
+/// verify(bird.canChirp(volume: any())).wasCalled()
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// // Protocol referencing Obj-C object types
-/// protocol Bird {
-/// func send(_ message: T) // Overloaded generically
-/// func send(_ message: NSString) // Overloaded explicitly
-/// func send(_ message: NSData)
-/// }
+/// ```swift
+/// // Protocol referencing Obj-C object types
+/// protocol Bird {
+/// func send(_ message: T) // Overloaded generically
+/// func send(_ message: NSString) // Overloaded explicitly
+/// func send(_ message: NSData)
+/// }
///
-/// given(bird.send(any(NSString.self))).will { print($0) }
+/// given(bird.send(any(NSString.self))).will { print($0) }
///
-/// bird.send("Hello") // Prints "Hello"
+/// bird.send("Hello") // Prints "Hello"
///
-/// verify(bird.send(any(NSString.self))).wasCalled()
-/// verify(bird.send(any(NSData.self))).wasNeverCalled()
+/// verify(bird.send(any(NSString.self))).wasCalled()
+/// verify(bird.send(any(NSData.self))).wasNeverCalled()
+/// ```
///
/// - Parameter type: The parameter type used to disambiguate overloaded methods.
public func any(_ type: T.Type = T.self) -> T {
@@ -91,31 +99,35 @@ public func any(_ type: T.Type = T.self) -> T {
/// Use the argument matcher `any(of:)` to match `Equatable` argument values equal to one or more of
/// the specified values.
///
-/// given(bird.canChirp(volume: any(of: 1, 3)))
-/// .willReturn(true)
+/// ```swift
+/// given(bird.canChirp(volume: any(of: 1, 3)))
+/// .willReturn(true)
///
-/// given(bird.canChirp(volume: any(of: 2, 4)))
-/// .willReturn(false)
+/// given(bird.canChirp(volume: any(of: 2, 4)))
+/// .willReturn(false)
///
-/// print(bird.canChirp(volume: 1)) // Prints "true"
-/// print(bird.canChirp(volume: 2)) // Prints "false"
-/// print(bird.canChirp(volume: 3)) // Prints "true"
-/// print(bird.canChirp(volume: 4)) // Prints "false"
+/// print(bird.canChirp(volume: 1)) // Prints "true"
+/// print(bird.canChirp(volume: 2)) // Prints "false"
+/// print(bird.canChirp(volume: 3)) // Prints "true"
+/// print(bird.canChirp(volume: 4)) // Prints "false"
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ message: T) // Overloaded generically
-/// func send(_ message: String) // Overloaded explicitly
-/// func send(_ message: Data)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: T) // Overloaded generically
+/// func send(_ message: String) // Overloaded explicitly
+/// func send(_ message: Data)
+/// }
///
-/// given(bird.send(any(String.self, of: "Hi", "Hello")))
-/// .will { print($0) }
+/// given(bird.send(any(String.self, of: "Hi", "Hello")))
+/// .will { print($0) }
///
-/// bird.send("Hi") // Prints "Hi"
-/// bird.send("Hello") // Prints "Hello"
-/// bird.send("Bye") // Error: Missing stubbed implementation
+/// bird.send("Hi") // Prints "Hi"
+/// bird.send("Hello") // Prints "Hello"
+/// bird.send("Bye") // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -134,50 +146,53 @@ public func any(_ type: T.Type = T.self, of objects: T...) -> T {
/// Matches argument values identical to any of the provided values.
///
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
-/// Use the argument matcher `any(of:)` to match objects identical to one or more of the specified
-/// values.
+/// Use the argument matcher `any(of:)` to match class instances by identity.
///
-/// // Reference type
-/// class Location {
-/// let name: String
-/// init(name: String) { self.name = name }
-/// }
+/// - Note: Only objects that don’t conform to `Equatable` are compared by reference.
///
-/// protocol Bird {
-/// func fly(to location: Location)
-/// }
+/// ```swift
+/// // Reference type
+/// class Location {
+/// let name: String
+/// init(_ name: String) { self.name = name }
+/// }
///
-/// let home = Location(name: "Home")
-/// let work = Location("Work")
-/// given(bird.fly(to: any(of: home, work)))
-/// .will { print($0.name) }
+/// protocol Bird {
+/// func fly(to location: Location)
+/// }
///
-/// bird.fly(to: home) // Prints "Home"
-/// bird.fly(to: work) // Prints "Work"
+/// let home = Location("Home")
+/// let work = Location("Work")
+/// given(bird.fly(to: any(of: home, work)))
+/// .will { print($0.name) }
///
-/// let hawaii = Location("Hawaii")
-/// bird.fly(to: hawaii)) // Error: Missing stubbed implementation
+/// bird.fly(to: home) // Prints "Home"
+/// bird.fly(to: work) // Prints "Work"
///
-/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
+/// let hawaii = Location("Hawaii")
+/// bird.fly(to: hawaii)) // Error: Missing stubbed implementation
+/// ```
///
-/// protocol Bird {
-/// func fly(to location: T) // Overloaded generically
-/// func fly(to location: Location) // Overloaded explicitly
-/// func fly(to locationName: String)
-/// }
+/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// given(bird.fly(to: any(String.self, of: "Home", "Work")))
-/// .will { print($0) }
+/// ```swift
+/// protocol Bird {
+/// func fly(to location: T) // Overloaded generically
+/// func fly(to location: Location) // Overloaded explicitly
+/// func fly(to locationName: String)
+/// }
///
-/// bird.send("Home") // Prints "Hi"
-/// bird.send("Work") // Prints "Hello"
-/// bird.send("Hawaii") // Error: Missing stubbed implementation
+/// given(bird.fly(to: any(String.self, of: "Home", "Work")))
+/// .will { print($0) }
///
-/// - Note: Objects are compared by reference.
+/// bird.send("Home") // Prints "Hi"
+/// bird.send("Work") // Prints "Hello"
+/// bird.send("Hawaii") // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
-/// - objects: A set of non-equatable objects that should result in a match.
+/// - objects: A set of reference type objects that should result in a match.
public func any(_ type: T.Type = T.self, of objects: T...) -> T {
let matcher = ArgumentMatcher(
nil as T?,
@@ -195,38 +210,42 @@ public func any(_ type: T.Type = T.self, of objects: T...) -> T {
/// Use the argument matcher `any(where:)` to match objects with custom equality logic. This is
/// particularly useful for parameter types that do not conform to `Equatable`.
///
-/// // Value type not explicitly conforming to `Equatable`
-/// struct Fruit {
-/// let size: Int
-/// }
+/// ```swift
+/// // Value type not explicitly conforming to `Equatable`
+/// struct Fruit {
+/// let size: Int
+/// }
///
-/// protocol Bird {
-/// func eat(_ fruit: Fruit)
-/// }
+/// protocol Bird {
+/// func eat(_ fruit: Fruit)
+/// }
///
-/// given(bird.eat(any(where: { $0.size < 100 })))
-/// .will { print($0.size) }
+/// given(bird.eat(any(where: { $0.size < 100 })))
+/// .will { print($0.size) }
///
-/// let apple = Fruit(size: 42)
-/// bird.eat(apple) // Prints "42"
+/// let apple = Fruit(size: 42)
+/// bird.eat(apple) // Prints "42"
///
-/// let pear = Fruit(size: 9001)
-/// bird.eat(pear) // Error: Missing stubbed implementation
+/// let pear = Fruit(size: 9001)
+/// bird.eat(pear) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func eat(_ object: T) // Overloaded generically
-/// func eat(_ fruit: Fruit) // Overloaded explicitly
-/// func eat(_ fruits: [Fruit])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func eat(_ object: T) // Overloaded generically
+/// func eat(_ fruit: Fruit) // Overloaded explicitly
+/// func eat(_ fruits: [Fruit])
+/// }
///
-/// given(bird.eat(any(Fruit.self, where: { $0.size < 100 })))
-/// .will { print($0) }
+/// given(bird.eat(any(Fruit.self, where: { $0.size < 100 })))
+/// .will { print($0) }
///
-/// let apple = Fruit(size: 42)
-/// bird.eat(apple) // Prints "42"
-/// bird.eat("Apple") // Error: Missing stubbed implementation
+/// let apple = Fruit(size: 42)
+/// bird.eat(apple) // Prints "42"
+/// bird.eat("Apple") // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -248,39 +267,43 @@ public func any(_ type: T.Type = T.self, where predicate: @escaping (_ value:
/// Use the argument matcher `any(where:)` to match objects with custom equality logic. This is
/// particularly useful for parameter types that do not conform to `Equatable`.
///
-/// // Non-equatable class subclassing `NSObject`
-/// class Fruit: NSObject {
-/// let size: Int
-/// init(size: Int) { self.size = size }
-/// }
+/// ```swift
+/// // Non-equatable class subclassing `NSObject`
+/// class Fruit: NSObject {
+/// let size: Int
+/// init(size: Int) { self.size = size }
+/// }
///
-/// protocol Bird {
-/// func eat(_ fruit: Fruit)
-/// }
+/// protocol Bird {
+/// func eat(_ fruit: Fruit)
+/// }
///
-/// given(bird.eat(any(where: { $0.size < 100 })))
-/// .will { print($0.size) }
+/// given(bird.eat(any(where: { $0.size < 100 })))
+/// .will { print($0.size) }
///
-/// let apple = Fruit(size: 42)
-/// bird.eat(apple) // Prints "42"
+/// let apple = Fruit(size: 42)
+/// bird.eat(apple) // Prints "42"
///
-/// let pear = Fruit(size: 9001)
-/// bird.eat(pear) // Error: Missing stubbed implementation
+/// let pear = Fruit(size: 9001)
+/// bird.eat(pear) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func eat(_ object: T) // Overloaded generically
-/// func eat(_ fruit: Fruit) // Overloaded explicitly
-/// func eat(_ fruits: [Fruit])
-/// }
+/// ```swift
+/// protocol Bird {
+/// func eat(_ object: T) // Overloaded generically
+/// func eat(_ fruit: Fruit) // Overloaded explicitly
+/// func eat(_ fruits: [Fruit])
+/// }
///
-/// given(bird.eat(any(Fruit.self, where: { $0.size < 100 })))
-/// .will { print($0) }
+/// given(bird.eat(any(Fruit.self, where: { $0.size < 100 })))
+/// .will { print($0) }
///
-/// let apple = Fruit(size: 42)
-/// bird.eat(apple) // Prints "42"
-/// bird.eat("Apple") // Error: Missing stubbed implementation
+/// let apple = Fruit(size: 42)
+/// bird.eat(apple) // Prints "42"
+/// bird.eat("Apple") // Error: Missing stubbed implementation
+/// ```
///
/// - Parameters:
/// - type: The parameter type used to disambiguate overloaded methods.
@@ -302,28 +325,32 @@ public func any(_ type: T.Type = T.self,
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
/// Use the argument matcher `notNil` to match non-nil argument values.
///
-/// protocol Bird {
-/// func send(_ message: String?)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: String?)
+/// }
///
-/// given(bird.send(notNil())).will { print($0) }
+/// given(bird.send(notNil())).will { print($0) }
///
-/// bird.send("Hello") // Prints Optional("Hello")
-/// bird.send(nil) // Error: Missing stubbed implementation
+/// bird.send("Hello") // Prints Optional("Hello")
+/// bird.send(nil) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// protocol Bird {
-/// func send(_ message: T?) // Overloaded generically
-/// func send(_ message: String?) // Overloaded explicitly
-/// func send(_ messages: Data?)
-/// }
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: T?) // Overloaded generically
+/// func send(_ message: String?) // Overloaded explicitly
+/// func send(_ messages: Data?)
+/// }
///
-/// given(bird.send(notNil(String?.self)))
-/// .will { print($0) }
+/// given(bird.send(notNil(String?.self)))
+/// .will { print($0) }
///
-/// bird.send("Hello") // Prints Optional("Hello")
-/// bird.send(nil) // Error: Missing stubbed implementation
+/// bird.send("Hello") // Prints Optional("Hello")
+/// bird.send(nil) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter type: The parameter type used to disambiguate overloaded methods.
public func notNil(_ type: T.Type = T.self) -> T {
@@ -341,30 +368,34 @@ public func notNil(_ type: T.Type = T.self) -> T {
/// Argument matching allows you to stub or verify specific invocations of parameterized methods.
/// Use the argument matcher `notNil` to match non-nil argument values.
///
-/// // Protocol referencing Obj-C object types
-/// protocol Bird {
-/// func send(_ message: NSString?)
-/// }
+/// ```swift
+/// // Protocol referencing Obj-C object types
+/// protocol Bird {
+/// func send(_ message: NSString?)
+/// }
///
-/// given(bird.send(notNil())).will { print($0) }
+/// given(bird.send(notNil())).will { print($0) }
///
-/// bird.send("Hello") // Prints Optional("Hello")
-/// bird.send(nil) // Error: Missing stubbed implementation
+/// bird.send("Hello") // Prints Optional("Hello")
+/// bird.send(nil) // Error: Missing stubbed implementation
+/// ```
///
/// Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
///
-/// // Protocol referencing Obj-C object types
-/// protocol Bird {
-/// func send(_ message: T?) // Overloaded generically
-/// func send(_ message: NSString?) // Overloaded explicitly
-/// func send(_ messages: NSData?)
-/// }
+/// ```swift
+/// // Protocol referencing Obj-C object types
+/// protocol Bird {
+/// func send(_ message: T?) // Overloaded generically
+/// func send(_ message: NSString?) // Overloaded explicitly
+/// func send(_ messages: NSData?)
+/// }
///
-/// given(bird.send(notNil(NSString?.self)))
-/// .will { print($0) }
+/// given(bird.send(notNil(NSString?.self)))
+/// .will { print($0) }
///
-/// bird.send("Hello") // Prints Optional("Hello")
-/// bird.send(nil) // Error: Missing stubbed implementation
+/// bird.send("Hello") // Prints Optional("Hello")
+/// bird.send(nil) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter type: The parameter type used to disambiguate overloaded methods.
public func notNil(_ type: T.Type = T.self) -> T {
diff --git a/Sources/MockingbirdFramework/Mocking/Mocking.swift b/Sources/MockingbirdFramework/Mocking/Mocking.swift
index 00a38f3b..cfc9b23d 100644
--- a/Sources/MockingbirdFramework/Mocking/Mocking.swift
+++ b/Sources/MockingbirdFramework/Mocking/Mocking.swift
@@ -12,21 +12,25 @@ import Foundation
/// Initialized mocks can be passed in place of the original type. Protocol mocks do not require
/// explicit initialization while class mocks should be created using `initialize(…)`.
///
-/// protocol Bird {
-/// init(name: String)
-/// }
-/// class Tree {
-/// init(with bird: Bird) {}
-/// }
-///
-/// let bird = mock(Bird.self) // Protocol mock
-/// let tree = mock(Tree.self).initialize(with: bird) // Class mock
+/// ```swift
+/// protocol Bird {
+/// init(name: String)
+/// }
+/// class Tree {
+/// init(with bird: Bird) {}
+/// }
+///
+/// let bird = mock(Bird.self) // Protocol mock
+/// let tree = mock(Tree.self).initialize(with: bird) // Class mock
+/// ```
///
/// Generated mock types are suffixed with `Mock` and should not be coerced into their supertype.
///
-/// let bird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
-/// let inferredBird = mock(Bird.self) // Type inference also works
-/// let coerced: Bird = mock(Bird.self) // Avoid upcasting mocks
+/// ```swift
+/// let bird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
+/// let inferredBird = mock(Bird.self) // Type inference also works
+/// let coerced: Bird = mock(Bird.self) // Avoid upcasting mocks
+/// ```
///
/// - Parameter type: The type to mock.
@available(*, unavailable, message: "No generated mock for this type which might be resolved by building the test target (⇧⌘U)")
@@ -37,29 +41,33 @@ public func mock(_ type: T.Type) -> T { fatalError() }
/// Initialized mocks can be passed in place of the original type. Dynamic mocks use the
/// Objective-C runtime and do not require explicit initialization like Swift class mocks.
///
-/// // Objective-C declarations
-/// @protocol Bird
-/// - (instancetype)initWithName:(NSString *);
-/// @end
-/// @interface Tree : NSObject
-/// - (instancetype)initWithHeight:(NSInteger)height;
-/// @end
+/// ```swift
+/// // Objective-C declarations
+/// @protocol Bird
+/// - (instancetype)initWithName:(NSString *);
+/// @end
+/// @interface Tree : NSObject
+/// - (instancetype)initWithHeight:(NSInteger)height;
+/// @end
///
-/// let bird = mock(Bird.self) // Protocol mock
-/// let tree = mock(Tree.self) // Class mock
+/// let bird = mock(Bird.self) // Protocol mock
+/// let tree = mock(Tree.self) // Class mock
+/// ```
///
/// It's also possible to mock Swift types inheriting from `NSObject` or conforming to
/// `NSObjectProtocol`. Members must be dynamically dispatched and available to the Objective-C
/// runtime by specifying the `objc` attribute and `dynamic` modifier.
///
-/// @objc protocol Bird: NSObjectProtocol {
-/// @objc dynamic func chirp()
-/// @objc dynamic var name: String { get }
-/// }
-/// @objc class Tree: NSObject {
-/// @objc dynamic func shake() {}
-/// @objc dynamic var height: Int
-/// }
+/// ```swift
+/// @objc protocol Bird: NSObjectProtocol {
+/// @objc dynamic func chirp()
+/// @objc dynamic var name: String { get }
+/// }
+/// @objc class Tree: NSObject {
+/// @objc dynamic func shake() {}
+/// @objc dynamic var height: Int
+/// }
+/// ```
///
/// - Parameter type: The type to mock.
public func mock(_ type: T.Type) -> T {
@@ -71,16 +79,18 @@ public func mock(_ type: T.Type) -> T {
/// Fully reset a set of mocks during test runs by removing all recorded invocations and clearing
/// all configurations.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// reset(bird)
+/// reset(bird)
///
-/// print(bird.name) // Error: Missing stubbed implementation
-/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// print(bird.name) // Error: Missing stubbed implementation
+/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// ```
///
/// - Parameter mocks: A set of mocks to reset.
public func reset(_ mocks: Mock...) {
@@ -90,23 +100,25 @@ public func reset(_ mocks: Mock...) {
})
}
-/// Remove all recorded invocations and configured stubs.
+/// Remove all recorded invocations and configured stubs for Objective-C mocks.
///
/// Fully reset a set of mocks during test runs by removing all recorded invocations and clearing
/// all configurations.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// reset(bird)
+/// reset(bird)
///
-/// print(bird.name) // Error: Missing stubbed implementation
-/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// print(bird.name) // Error: Missing stubbed implementation
+/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// ```
///
-/// - Parameter mocks: A set of mocks to reset.
+/// - Parameter mocks: A set of Objective-C mocks to reset.
public func reset(_ mocks: NSObjectProtocol...) {
mocks.forEach({ mock in
clearInvocations(on: mock)
@@ -118,38 +130,42 @@ public func reset(_ mocks: NSObjectProtocol...) {
///
/// Partially reset a set of mocks during test runs by removing all recorded invocations.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// clearInvocations(on: bird)
+/// clearInvocations(on: bird)
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// ```
///
/// - Parameter mocks: A set of mocks to reset.
public func clearInvocations(on mocks: Mock...) {
mocks.forEach({ $0.mockingbirdContext.mocking.clearInvocations() })
}
-/// Remove all recorded invocations.
+/// Remove all recorded invocations for Objective-C mocks.
///
/// Partially reset a set of mocks during test runs by removing all recorded invocations.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// clearInvocations(on: bird)
+/// clearInvocations(on: bird)
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Error: Got 0 invocations
+/// ```
///
-/// - Parameter mocks: A set of mocks to reset.
+/// - Parameter mocks: A set of Objective-C mocks to reset.
public func clearInvocations(on mocks: NSObjectProtocol...) {
mocks.forEach({ mock in
guard let context = mock.mockingbirdContext else { return }
@@ -161,15 +177,17 @@ public func clearInvocations(on mocks: NSObjectProtocol...) {
///
/// Partially reset a set of mocks during test runs by removing all stubs.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// clearStubs(on: bird)
+/// clearStubs(on: bird)
///
-/// print(bird.name) // Error: Missing stubbed implementation
+/// print(bird.name) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter mocks: A set of mocks to reset.
public func clearStubs(on mocks: Mock...) {
@@ -181,19 +199,21 @@ public func clearStubs(on mocks: Mock...) {
})
}
-/// Remove all concrete stubs.
+/// Remove all concrete stubs for Objective-C mocks.
///
/// Partially reset a set of mocks during test runs by removing all stubs.
///
-/// let bird = mock(Bird.self)
-/// given(bird.name).willReturn("Ryan")
+/// ```swift
+/// let bird = mock(Bird.self)
+/// given(bird.name).willReturn("Ryan")
///
-/// print(bird.name) // Prints "Ryan"
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints "Ryan"
+/// verify(bird.name).wasCalled() // Passes
///
-/// clearStubs(on: bird)
+/// clearStubs(on: bird)
///
-/// print(bird.name) // Error: Missing stubbed implementation
+/// print(bird.name) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter mocks: A set of mocks to reset.
public func clearStubs(on mocks: NSObjectProtocol...) {
@@ -209,15 +229,17 @@ public func clearStubs(on mocks: NSObjectProtocol...) {
///
/// Partially reset a set of mocks during test runs by removing all registered default values.
///
-/// let bird = mock(Bird.self)
-/// bird.useDefaultValues(from: .standardProvider)
+/// ```swift
+/// let bird = mock(Bird.self)
+/// bird.useDefaultValues(from: .standardProvider)
///
-/// print(bird.name) // Prints ""
-/// verify(bird.name).wasCalled() // Passes
+/// print(bird.name) // Prints ""
+/// verify(bird.name).wasCalled() // Passes
///
-/// clearDefaultValues(on: bird)
+/// clearDefaultValues(on: bird)
///
-/// print(bird.name) // Error: Missing stubbed implementation
+/// print(bird.name) // Error: Missing stubbed implementation
+/// ```
///
/// - Parameter mocks: A set of mocks to reset.
@available(*, deprecated, renamed: "clearStubs")
diff --git a/Sources/MockingbirdFramework/Objective-C/Bridge/include/MKBTestUtils.h b/Sources/MockingbirdFramework/Objective-C/Bridge/include/MKBTestUtils.h
index 8f4f9cc6..482b7511 100644
--- a/Sources/MockingbirdFramework/Objective-C/Bridge/include/MKBTestUtils.h
+++ b/Sources/MockingbirdFramework/Objective-C/Bridge/include/MKBTestUtils.h
@@ -21,13 +21,15 @@ NSException *_Nullable MKBTryBlock(void(^_Nonnull NS_NOESCAPE block)(void));
///
/// Fully type erased optionals in Swift causes typical `nil` checks to fail. For example:
///
-/// func erase(_ value: T) {
-/// print(value == nil) // false
-/// print(value as Optional == nil) // false
-/// print(value as? Optional == nil) // false
-/// print(value as! Optional == nil) // true
-/// }
-/// erase(Optional(nil))
+/// ```swift
+/// func erase(_ value: T) {
+/// print(value == nil) // false
+/// print(value as Optional == nil) // false
+/// print(value as? Optional == nil) // false
+/// print(value as! Optional == nil) // true
+/// }
+/// erase(Optional(nil))
+/// ```
///
/// Since Objective-C implicitly bridges to `NSNull`, an easy (albeit hacky) way to check if the
/// value is both an `Optional` and `nil` at runtime is to pass it Objective-C. Swift does support
diff --git a/Sources/MockingbirdFramework/Stubbing/DefaultValues.swift b/Sources/MockingbirdFramework/Stubbing/DefaultValues.swift
index 79250377..9ce44273 100644
--- a/Sources/MockingbirdFramework/Stubbing/DefaultValues.swift
+++ b/Sources/MockingbirdFramework/Stubbing/DefaultValues.swift
@@ -14,32 +14,40 @@ public extension Mock {
/// Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
/// failure. Methods returning Void do not need to be stubbed in strict mode.
///
- /// let bird = mock(Bird.self)
- /// print(bird.name) // Fails because `bird.name` is not stubbed
- /// bird.fly() // Okay because `fly()` has a `Void` return type
+ /// ```swift
+ /// let bird = mock(Bird.self)
+ /// print(bird.name) // Fails because `bird.name` is not stubbed
+ /// bird.fly() // Okay because `fly()` has a `Void` return type
+ /// ```
///
/// To return default values for unstubbed methods, use a `ValueProvider` with the initialized
/// mock. Mockingbird provides preset value providers which are guaranteed to be backwards
/// compatible, such as `.standardProvider`.
///
- /// bird.useDefaultValues(from: .standardProvider)
- /// print(bird.name) // Prints ""
+ /// ```swift
+ /// bird.useDefaultValues(from: .standardProvider)
+ /// print(bird.name) // Prints ""
+ /// ```
///
/// You can create custom value providers by registering values for types. See `Providable` for
/// how to provide "wildcard" instances for generic types.
///
- /// var valueProvider = ValueProvider(from: .standardProvider)
- /// valueProvider.register("Ryan", for: String.self)
- /// bird.useDefaultValues(from: valueProvider)
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// var valueProvider = ValueProvider(from: .standardProvider)
+ /// valueProvider.register("Ryan", for: String.self)
+ /// bird.useDefaultValues(from: valueProvider)
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Values from concrete stubs always have a higher precedence than default values.
///
- /// given(bird.name) ~> "Ryan"
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// given(bird.name) ~> "Ryan"
+ /// print(bird.name) // Prints "Ryan"
///
- /// bird.useDefaultValues(from: .standardProvider)
- /// print(bird.name) // Prints "Ryan"
+ /// bird.useDefaultValues(from: .standardProvider)
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// - Note: This does not remove previously added value providers.
///
@@ -58,32 +66,40 @@ public extension NSObjectProtocol {
/// Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
/// failure. Methods returning Void do not need to be stubbed in strict mode.
///
- /// let bird = mock(Bird.self)
- /// print(bird.name) // Fails because `bird.name` is not stubbed
- /// bird.fly() // Okay because `fly()` has a `Void` return type
+ /// ```swift
+ /// let bird = mock(Bird.self)
+ /// print(bird.name) // Fails because `bird.name` is not stubbed
+ /// bird.fly() // Okay because `fly()` has a `Void` return type
+ /// ```
///
/// To return default values for unstubbed methods, use a `ValueProvider` with the initialized
/// mock. Mockingbird provides preset value providers which are guaranteed to be backwards
/// compatible, such as `.standardProvider`.
///
- /// bird.useDefaultValues(from: .standardProvider)
- /// print(bird.name) // Prints ""
+ /// ```swift
+ /// bird.useDefaultValues(from: .standardProvider)
+ /// print(bird.name) // Prints ""
+ /// ```
///
/// You can create custom value providers by registering values for types. See `Providable` for
/// how to provide "wildcard" instances for generic types.
///
- /// var valueProvider = ValueProvider(from: .standardProvider)
- /// valueProvider.register("Ryan", for: String.self)
- /// bird.useDefaultValues(from: valueProvider)
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// var valueProvider = ValueProvider(from: .standardProvider)
+ /// valueProvider.register("Ryan", for: String.self)
+ /// bird.useDefaultValues(from: valueProvider)
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Values from concrete stubs always have a higher precedence than default values.
///
- /// given(bird.name) ~> "Ryan"
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// given(bird.name) ~> "Ryan"
+ /// print(bird.name) // Prints "Ryan"
///
- /// bird.useDefaultValues(from: .standardProvider)
- /// print(bird.name) // Prints "Ryan"
+ /// bird.useDefaultValues(from: .standardProvider)
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// - Note: This does not remove previously added value providers.
///
diff --git a/Sources/MockingbirdFramework/Stubbing/DynamicStubbingManager.swift b/Sources/MockingbirdFramework/Stubbing/DynamicStubbingManager.swift
index 92e92d8a..bb63a5ae 100644
--- a/Sources/MockingbirdFramework/Stubbing/DynamicStubbingManager.swift
+++ b/Sources/MockingbirdFramework/Stubbing/DynamicStubbingManager.swift
@@ -18,15 +18,19 @@ public class DynamicStubbingManager:
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
- /// given(bird.doMethod()).willReturn(someValue)
- /// given(bird.property).willReturn(someValue)
+ /// ```swift
+ /// given(bird.doMethod()).willReturn(someValue)
+ /// given(bird.property).willReturn(someValue)
+ /// ```
///
/// Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
/// later have a higher precedence, so add stubs with specific matchers last.
///
- /// given(bird.canChirp(volume: any())).willReturn(true) // Any volume
- /// given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
- /// given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
+ /// ```swift
+ /// given(bird.canChirp(volume: any())).willReturn(true) // Any volume
+ /// given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
+ /// given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
+ /// ```
///
/// - Parameter value: A stubbed value to return.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -40,8 +44,10 @@ public class DynamicStubbingManager:
/// Stubbing allows you to define custom behavior for mocks to perform. Methods that throw or
/// rethrow errors can be stubbed with a throwable object.
///
- /// struct BirdError: Error {}
- /// given(bird.throwingMethod()).willThrow(BirdError())
+ /// ```swift
+ /// struct BirdError: Error {}
+ /// given(bird.throwingMethod()).willThrow(BirdError())
+ /// ```
///
/// - Note: Methods overloaded by return type should chain `returning` with `willThrow` to
/// disambiguate the mocked declaration.
@@ -62,10 +68,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -82,10 +90,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -103,10 +113,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -124,10 +136,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -145,10 +159,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -166,10 +182,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -187,10 +205,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -208,10 +228,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -230,10 +252,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -252,10 +276,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -274,10 +300,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -298,10 +326,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -318,10 +348,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -339,10 +371,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -360,10 +394,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -381,10 +417,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -402,10 +440,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -423,10 +463,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -444,10 +486,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -466,10 +510,12 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// ```swift
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -488,10 +534,10 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -510,10 +556,10 @@ public class DynamicStubbingManager:
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
- /// given(bird.canChirp(volume: any()))
- /// .will { volume in
- /// return volume < 42
- /// }
+ /// given(bird.canChirp(volume: any()))
+ /// .will { volume in
+ /// return volume < 42
+ /// }
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
diff --git a/Sources/MockingbirdFramework/Stubbing/InvocationForwarding.swift b/Sources/MockingbirdFramework/Stubbing/InvocationForwarding.swift
index f0265fcb..fd59a462 100644
--- a/Sources/MockingbirdFramework/Stubbing/InvocationForwarding.swift
+++ b/Sources/MockingbirdFramework/Stubbing/InvocationForwarding.swift
@@ -19,28 +19,32 @@ public struct ForwardingContext {
/// Superclass forwarding persists until removed with `clearStubs` or shadowed by a forwarding
/// target that was added afterwards.
///
-/// class Bird {
-/// let name: String
-/// init(name: String) { self.name = name }
-/// }
+/// ```swift
+/// class Bird {
+/// let name: String
+/// init(name: String) { self.name = name }
+/// }
///
-/// // `BirdMock` subclasses `Bird`
-/// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
+/// // `BirdMock` subclasses `Bird`
+/// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
///
-/// given(bird.name) ~> forwardToSuper()
-/// print(bird.name) // Prints "Ryan"
+/// given(bird.name) ~> forwardToSuper()
+/// print(bird.name) // Prints "Ryan"
+/// ```
///
/// The mocked type must be a class. Adding superclass forwarding to mocked protocol declarations
/// is a no-op.
///
-/// // Not a class
-/// protocol AbstractBird {
-/// var name: String { get }
-/// }
+/// ```swift
+/// // Not a class
+/// protocol AbstractBird {
+/// var name: String { get }
+/// }
///
-/// let bird = mock(AbstractBird.self)
-/// given(bird.name) ~> forwardToSuper()
-/// print(bird.name) // Error: Missing stubbed implementation
+/// let bird = mock(AbstractBird.self)
+/// given(bird.name) ~> forwardToSuper()
+/// print(bird.name) // Error: Missing stubbed implementation
+/// ```
///
/// - Note: To forward all calls by default to the superclass, use `forwardCallsToSuper` on the mock
/// instance instead.
@@ -54,35 +58,41 @@ public func forwardToSuper() -> ForwardingContext {
/// Targets added afterwards have a higher precedence and only pass calls down the forwarding chain
/// if unable handle the invocation, such as when the target is unrelated to the mocked type.
///
-/// class Crow: Bird {
-/// let name: String
-/// init(name: String) { self.name = name }
-/// }
+/// ```swift
+/// class Crow: Bird {
+/// let name: String
+/// init(name: String) { self.name = name }
+/// }
///
-/// given(bird.name) ~> forward(to: Crow(name: "Ryan"))
-/// print(bird.name) // Prints "Ryan"
+/// given(bird.name) ~> forward(to: Crow(name: "Ryan"))
+/// print(bird.name) // Prints "Ryan"
///
-/// // Additional targets take precedence
-/// given(bird.name) ~> forward(to: Crow(name: "Sterling"))
-/// print(bird.name) // Prints "Sterling"
+/// // Additional targets take precedence
+/// given(bird.name) ~> forward(to: Crow(name: "Sterling"))
+/// print(bird.name) // Prints "Sterling"
+/// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
-/// given(bird.name) ~> "Ryan"
-/// given(bird.name) ~> forward(to: Crow(name: "Sterling"))
-/// print(bird.name) // Prints "Ryan"
+/// ```swift
+/// given(bird.name) ~> "Ryan"
+/// given(bird.name) ~> forward(to: Crow(name: "Sterling"))
+/// print(bird.name) // Prints "Ryan"
+/// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
-/// // Not a `Bird`
-/// class Person {
-/// var name = "Ryan"
-/// }
+/// ```swift
+/// // Not a `Bird`
+/// class Person {
+/// var name = "Ryan"
+/// }
///
-/// given(bird.name) ~> forward(to: Person())
-/// print(bird.name) // Error: Missing stubbed implementation
+/// given(bird.name) ~> forward(to: Person())
+/// print(bird.name) // Error: Missing stubbed implementation
+/// ```
///
/// - Note: To forward all calls to an object, use `forwardCalls` on the mock instance instead.
///
@@ -98,28 +108,32 @@ public extension StubbingManager {
/// receiving a matching invocation. Superclass forwarding persists until removed with
/// `clearStubs` or shadowed by a forwarding target that was added afterwards.
///
- /// class Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// // `BirdMock` subclasses `Bird`
- /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
+ /// // `BirdMock` subclasses `Bird`
+ /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
///
- /// given(bird.name).willForwardToSuper()
- /// print(bird.name) // Prints "Ryan"
+ /// given(bird.name).willForwardToSuper()
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// The mocked type must be a class. Adding superclass forwarding to mocked protocol declarations
/// is a no-op.
///
- /// // Not a class
- /// protocol AbstractBird {
- /// var name: String { get }
- /// }
+ /// ```swift
+ /// // Not a class
+ /// protocol AbstractBird {
+ /// var name: String { get }
+ /// }
///
- /// let bird = mock(AbstractBird.self)
- /// given(bird.name).willForwardToSuper()
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// let bird = mock(AbstractBird.self)
+ /// given(bird.name).willForwardToSuper()
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Note: To forward all calls by default to the superclass, use `forwardCallsToSuper` on the
/// mock instance instead.
@@ -137,35 +151,41 @@ public extension StubbingManager {
/// forwarding chain if unable handle the invocation, such as when the target is unrelated to the
/// mocked type.
///
- /// class Crow: Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Crow: Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// given(bird.name).willForward(to: Crow(name: "Ryan"))
- /// print(bird.name) // Prints "Ryan"
+ /// given(bird.name).willForward(to: Crow(name: "Ryan"))
+ /// print(bird.name) // Prints "Ryan"
///
- /// // Additional targets take precedence
- /// given(bird.name).willForward(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Sterling"
+ /// // Additional targets take precedence
+ /// given(bird.name).willForward(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Sterling"
+ /// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
- /// given(bird.name).willReturn("Ryan")
- /// given(bird.name).willForward(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// given(bird.name).willReturn("Ryan")
+ /// given(bird.name).willForward(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
- /// // Not a `Bird`
- /// class Person {
- /// var name = "Ryan"
- /// }
+ /// ```swift
+ /// // Not a `Bird`
+ /// class Person {
+ /// var name = "Ryan"
+ /// }
///
- /// given(bird.name).willForward(to: Person())
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// given(bird.name).willForward(to: Person())
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Note: To forward all calls to an object, use `forwardCalls` on the mock instance instead.
///
@@ -183,36 +203,42 @@ public extension Mock {
/// forwarding persists until removed with `clearStubs` or shadowed by a forwarding target that
/// was added afterwards.
///
- /// class Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// // `BirdMock` subclasses `Bird`
- /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
+ /// // `BirdMock` subclasses `Bird`
+ /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
///
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Prints "Ryan"
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
- /// let bird = mock(Bird.self).initialize(name: "Sterling")
- /// given(bird.name).willReturn("Ryan")
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// let bird = mock(Bird.self).initialize(name: "Sterling")
+ /// given(bird.name).willReturn("Ryan")
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
- /// // Not a class
- /// protocol AbstractBird {
- /// var name: String { get }
- /// }
+ /// ```swift
+ /// // Not a class
+ /// protocol AbstractBird {
+ /// var name: String { get }
+ /// }
///
- /// let bird = mock(AbstractBird.self)
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// let bird = mock(AbstractBird.self)
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Returns: A partial mock using the superclass to handle invocations.
@discardableResult
@@ -227,36 +253,42 @@ public extension Mock {
/// `clearStubs`. Targets added afterwards have a higher precedence and only pass calls down the forwarding chain if unable handle the invocation, such as when the target is unrelated to the
/// mocked type.
///
- /// class Crow: Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Crow: Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// let bird = mock(Bird.self)
- /// bird.forwardCalls(to: Crow(name: "Ryan"))
- /// print(bird.name) // Prints "Ryan"
+ /// let bird = mock(Bird.self)
+ /// bird.forwardCalls(to: Crow(name: "Ryan"))
+ /// print(bird.name) // Prints "Ryan"
///
- /// // Additional targets take precedence
- /// bird.forwardCalls(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Sterling"
+ /// // Additional targets take precedence
+ /// bird.forwardCalls(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Sterling"
+ /// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
- /// given(bird.name).willReturn("Ryan")
- /// bird.forwardCalls(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// given(bird.name).willReturn("Ryan")
+ /// bird.forwardCalls(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
- /// // Not a `Bird`
- /// class Person {
- /// var name = "Ryan"
- /// }
+ /// ```swift
+ /// // Not a `Bird`
+ /// class Person {
+ /// var name = "Ryan"
+ /// }
///
- /// bird.forwardCalls(to: Person())
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// bird.forwardCalls(to: Person())
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Parameter object: An object that should handle forwarded invocations.
/// - Returns: A partial mock using `object` to handle invocations.
@@ -274,36 +306,42 @@ public extension NSObjectProtocol {
/// forwarding persists until removed with `clearStubs` or shadowed by a forwarding target that
/// was added afterwards.
///
- /// class Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// // `BirdMock` subclasses `Bird`
- /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
+ /// // `BirdMock` subclasses `Bird`
+ /// let bird: BirdMock = mock(Bird.self).initialize(name: "Ryan")
///
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Prints "Ryan"
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
- /// let bird = mock(Bird.self).initialize(name: "Sterling")
- /// given(bird.name).willReturn("Ryan")
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// let bird = mock(Bird.self).initialize(name: "Sterling")
+ /// given(bird.name).willReturn("Ryan")
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
- /// // Not a class
- /// protocol AbstractBird {
- /// var name: String { get }
- /// }
+ /// ```swift
+ /// // Not a class
+ /// protocol AbstractBird {
+ /// var name: String { get }
+ /// }
///
- /// let bird = mock(AbstractBird.self)
- /// bird.forwardCallsToSuper()
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// let bird = mock(AbstractBird.self)
+ /// bird.forwardCallsToSuper()
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Returns: A partial mock using the superclass to handle invocations.
@discardableResult
@@ -318,36 +356,42 @@ public extension NSObjectProtocol {
/// `clearStubs`. Targets added afterwards have a higher precedence and only pass calls down the forwarding chain if unable handle the invocation, such as when the target is unrelated to the
/// mocked type.
///
- /// class Crow: Bird {
- /// let name: String
- /// init(name: String) { self.name = name }
- /// }
+ /// ```swift
+ /// class Crow: Bird {
+ /// let name: String
+ /// init(name: String) { self.name = name }
+ /// }
///
- /// let bird = mock(Bird.self)
- /// bird.forwardCalls(to: Crow(name: "Ryan"))
- /// print(bird.name) // Prints "Ryan"
+ /// let bird = mock(Bird.self)
+ /// bird.forwardCalls(to: Crow(name: "Ryan"))
+ /// print(bird.name) // Prints "Ryan"
///
- /// // Additional targets take precedence
- /// bird.forwardCalls(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Sterling"
+ /// // Additional targets take precedence
+ /// bird.forwardCalls(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Sterling"
+ /// ```
///
/// Concrete stubs always have a higher priority than forwarding targets, regardless of the order
/// they were added.
///
- /// given(bird.name).willReturn("Ryan")
- /// bird.forwardCalls(to: Crow(name: "Sterling"))
- /// print(bird.name) // Prints "Ryan"
+ /// ```swift
+ /// given(bird.name).willReturn("Ryan")
+ /// bird.forwardCalls(to: Crow(name: "Sterling"))
+ /// print(bird.name) // Prints "Ryan"
+ /// ```
///
/// Objects must inherit from the mocked type to handle forwarded invocations, even if the
/// declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
///
- /// // Not a `Bird`
- /// class Person {
- /// var name = "Ryan"
- /// }
+ /// ```swift
+ /// // Not a `Bird`
+ /// class Person {
+ /// var name = "Ryan"
+ /// }
///
- /// bird.forwardCalls(to: Person())
- /// print(bird.name) // Error: Missing stubbed implementation
+ /// bird.forwardCalls(to: Person())
+ /// print(bird.name) // Error: Missing stubbed implementation
+ /// ```
///
/// - Parameter object: An object that should handle forwarded invocations.
/// - Returns: A partial mock using `object` to handle invocations.
diff --git a/Sources/MockingbirdFramework/Stubbing/PropertyProviders.swift b/Sources/MockingbirdFramework/Stubbing/PropertyProviders.swift
index 0c8855ed..1a25e9d5 100644
--- a/Sources/MockingbirdFramework/Stubbing/PropertyProviders.swift
+++ b/Sources/MockingbirdFramework/Stubbing/PropertyProviders.swift
@@ -12,10 +12,12 @@ import Foundation
/// Getters can be stubbed to automatically save and return values.
/// with property getters to automatically save and return values.
///
-/// given(bird.name).willReturn(lastSetValue(initial: ""))
-/// print(bird.name) // Prints ""
-/// bird.name = "Ryan"
-/// print(bird.name) // Prints "Ryan"
+/// ```swift
+/// given(bird.name).willReturn(lastSetValue(initial: ""))
+/// print(bird.name) // Prints ""
+/// bird.name = "Ryan"
+/// print(bird.name) // Prints "Ryan"
+/// ```
///
/// - Parameter initial: The initial value to return.
public func lastSetValue(
diff --git a/Sources/MockingbirdFramework/Stubbing/SequenceProviders.swift b/Sources/MockingbirdFramework/Stubbing/SequenceProviders.swift
index 92da6045..48ff9d76 100644
--- a/Sources/MockingbirdFramework/Stubbing/SequenceProviders.swift
+++ b/Sources/MockingbirdFramework/Stubbing/SequenceProviders.swift
@@ -34,12 +34,14 @@ enum SequenceType {
/// Provide one or more values which will be returned sequentially for each invocation. The last
/// value will be used if the number of invocations is greater than the number of values provided.
///
-/// given(bird.name)
-/// .willReturn(sequence(of: "Ryan", "Sterling"))
+/// ```swift
+/// given(bird.name)
+/// .willReturn(sequence(of: "Ryan", "Sterling"))
///
-/// print(bird.name) // Prints "Ryan"
-/// print(bird.name) // Prints "Sterling"
-/// print(bird.name) // Prints "Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// print(bird.name) // Prints "Sterling"
+/// print(bird.name) // Prints "Sterling"
+/// ```
///
/// - Parameter values: A sequence of values to stub.
public func sequence(
@@ -54,15 +56,17 @@ public func sequence(
/// last implementation will be used if the number of invocations is greater than the number of
/// implementations provided.
///
-/// given(bird.name).willReturn(sequence(of: {
-/// return Bool.random() ? "Ryan" : "Meisters"
-/// }, {
-/// return Bool.random() ? "Sterling" : "Hackley"
-/// }))
+/// ```swift
+/// given(bird.name).willReturn(sequence(of: {
+/// return Bool.random() ? "Ryan" : "Meisters"
+/// }, {
+/// return Bool.random() ? "Sterling" : "Hackley"
+/// }))
///
-/// print(bird.name) // Prints "Ryan"
-/// print(bird.name) // Prints "Sterling"
-/// print(bird.name) // Prints "Hackley"
+/// print(bird.name) // Prints "Ryan"
+/// print(bird.name) // Prints "Sterling"
+/// print(bird.name) // Prints "Hackley"
+/// ```
///
/// - Parameter implementations: A sequence of implementations to stub.
public func sequence(
@@ -77,13 +81,15 @@ public func sequence(
/// will loop from the beginning if the number of invocations is greater than the number of values
/// provided.
///
-/// given(bird.name)
-/// .willReturn(loopingSequence(of: "Ryan", "Sterling"))
+/// ```swift
+/// given(bird.name)
+/// .willReturn(loopingSequence(of: "Ryan", "Sterling"))
///
-/// print(bird.name) // Prints "Ryan"
-/// print(bird.name) // Prints "Sterling"
-/// print(bird.name) // Prints "Ryan"
-/// print(bird.name) // Prints "Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// print(bird.name) // Prints "Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// print(bird.name) // Prints "Sterling"
+/// ```
///
/// - Parameter values: A sequence of values to stub.
public func loopingSequence(
@@ -98,16 +104,18 @@ public func loopingSequence(
@@ -121,12 +129,14 @@ public func loopingSequence(
@@ -141,15 +151,17 @@ public func finiteSequence(
diff --git a/Sources/MockingbirdFramework/Stubbing/Stubbing+ObjC.swift b/Sources/MockingbirdFramework/Stubbing/Stubbing+ObjC.swift
index 78611efc..4a1f00fc 100644
--- a/Sources/MockingbirdFramework/Stubbing/Stubbing+ObjC.swift
+++ b/Sources/MockingbirdFramework/Stubbing/Stubbing+ObjC.swift
@@ -7,19 +7,23 @@
import Foundation
-/// Stub a mocked method or property by returning a single value.
+/// Stub a mocked Objective-C method or property by returning a single value.
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
-/// given(bird.doMethod()) ~> someValue
-/// given(bird.property) ~> someValue
+/// ```swift
+/// given(bird.doMethod()) ~> someValue
+/// given(bird.property) ~> someValue
+/// ```
///
/// Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
/// later have a higher precedence, so add stubs with specific matchers last.
///
-/// given(bird.canChirp(volume: any())) ~> true // Any volume
-/// given(bird.canChirp(volume: notNil())) ~> true // Any non-nil volume
-/// given(bird.canChirp(volume: 10)) ~> true // Volume = 10
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> true // Any volume
+/// given(bird.canChirp(volume: notNil())) ~> true // Any non-nil volume
+/// given(bird.canChirp(volume: 10)) ~> true // Volume = 10
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -34,13 +38,15 @@ public func ~> (
// MARK: - Non-throwing
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -54,13 +60,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -75,13 +83,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -96,13 +106,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -117,13 +129,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -138,13 +152,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -159,13 +175,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -180,13 +198,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -202,13 +222,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -224,13 +246,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -246,13 +270,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -272,13 +298,15 @@ public func ~> (
// MARK: - Throwing
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -292,13 +320,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -313,13 +343,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -334,13 +366,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -355,13 +389,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -376,13 +412,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -397,13 +435,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -418,13 +458,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -440,13 +482,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -462,13 +506,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -484,13 +530,15 @@ public func ~> (
})
}
-/// Stub a mocked method or property with a closure implementation.
+/// Stub a mocked Objective-C method or property with a closure implementation.
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
diff --git a/Sources/MockingbirdFramework/Stubbing/Stubbing.swift b/Sources/MockingbirdFramework/Stubbing/Stubbing.swift
index fa750b3a..7e9a0d19 100644
--- a/Sources/MockingbirdFramework/Stubbing/Stubbing.swift
+++ b/Sources/MockingbirdFramework/Stubbing/Stubbing.swift
@@ -13,44 +13,52 @@ import XCTest
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
-/// protocol Bird {
-/// var name: String { get }
-/// func chirp(at volume: Int) throws -> Bool
-/// }
-///
-/// given(bird.name).willReturn("Ryan")
-/// given(bird.chirp(at: 42)).willThrow(BirdError())
-/// given(bird.chirp(at: any())).will { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// protocol Bird {
+/// var name: String { get }
+/// func chirp(at volume: Int) throws -> Bool
+/// }
+///
+/// given(bird.name).willReturn("Ryan")
+/// given(bird.chirp(at: 42)).willThrow(BirdError())
+/// given(bird.chirp(at: any())).will { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// This is equivalent to the shorthand syntax using the stubbing operator `~>`.
///
-/// given(bird.name) ~> "Ryan"
-/// given(bird.chirp(at: 42)) ~> { throw BirdError() }
-/// given(bird.chirp(at: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.name) ~> "Ryan"
+/// given(bird.chirp(at: 42)) ~> { throw BirdError() }
+/// given(bird.chirp(at: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// Properties can have stubs on both their getters and setters.
///
-/// given(bird.name).willReturn("Ryan")
-/// given(bird.name = any()).will {
-/// print("Hello \($0)")
-/// }
+/// ```swift
+/// given(bird.name).willReturn("Ryan")
+/// given(bird.name = any()).will {
+/// print("Hello \($0)")
+/// }
///
-/// print(bird.name) // Prints "Ryan"
-/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// ```
///
/// This is equivalent to using the synthesized getter and setter methods.
///
-/// given(bird.getName()).willReturn("Ryan")
-/// given(bird.setName(any())).will {
-/// print("Hello \($0)")
-/// }
+/// ```swift
+/// given(bird.getName()).willReturn("Ryan")
+/// given(bird.setName(any())).will {
+/// print("Hello \($0)")
+/// }
///
-/// print(bird.name) // Prints "Ryan"
-/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// ```
///
/// - Parameter declaration: A stubbable declaration.
public func given(
@@ -60,33 +68,39 @@ public func given(
context: declaration.mock.mockingbirdContext)
}
-/// Stub a declaration to return a value or perform an operation.
+/// Stub an Objective-C or property declaration to return a value or perform an operation.
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
-/// given(bird.canChirp()).willReturn(true)
-/// given(bird.canChirp()).willThrow(BirdError())
-/// given(bird.canChirp(volume: any())).will { volume in
-/// return volume as Int < 42
-/// }
+/// ```swift
+/// given(bird.canChirp()).willReturn(true)
+/// given(bird.canChirp()).willThrow(BirdError())
+/// given(bird.canChirp(volume: any())).will { volume in
+/// return volume as Int < 42
+/// }
+/// ```
///
/// This is equivalent to the shorthand syntax using the stubbing operator `~>`.
///
-/// given(bird.canChirp()) ~> true
-/// given(bird.canChirp()) ~> { throw BirdError() }
-/// given(bird.canChirp(volume: any()) ~> { volume in
-/// return volume as Int < 42
-/// }
+/// ```swift
+/// given(bird.canChirp()) ~> true
+/// given(bird.canChirp()) ~> { throw BirdError() }
+/// given(bird.canChirp(volume: any()) ~> { volume in
+/// return volume as Int < 42
+/// }
+/// ```
///
/// Properties can have stubs on both their getters and setters.
///
-/// given(bird.name).willReturn("Ryan")
-/// given(bird.name = any()).will { (name: String) in
-/// print("Hello \(name)")
-/// }
+/// ```swift
+/// given(bird.name).willReturn("Ryan")
+/// given(bird.name = any()).will { (name: String) in
+/// print("Hello \(name)")
+/// }
///
-/// print(bird.name) // Prints "Ryan"
-/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// print(bird.name) // Prints "Ryan"
+/// bird.name = "Sterling" // Prints "Hello Sterling"
+/// ```
///
/// - Parameter declaration: A stubbable declaration.
public func given(
@@ -136,14 +150,16 @@ public class StubbingManager Void)
- /// }
+ /// ```swift
+ /// protocol Bird {
+ /// func send(_ message: inout String)
+ /// func fly(callback: (Result) -> Void)
+ /// }
///
- /// // Inout parameter type
- /// var message = "Hello!"
- /// given(bird.send(message: any())).will { message in
- /// message = message.uppercased()
- /// }
- /// bird.send(&message)
- /// print(message) // Prints "HELLO!"
+ /// // Inout parameter type
+ /// var message = "Hello!"
+ /// given(bird.send(message: any())).will { message in
+ /// message = message.uppercased()
+ /// }
+ /// bird.send(&message)
+ /// print(message) // Prints "HELLO!"
///
- /// // Closure parameter type
- /// given(bird.fly(callback: any())).will { callback in
- /// callback(.success)
- /// }
- /// bird.fly(callback: { result in
- /// print(result) // Prints Result.success
- /// })
+ /// // Closure parameter type
+ /// given(bird.fly(callback: any())).will { callback in
+ /// callback(.success)
+ /// }
+ /// bird.fly(callback: { result in
+ /// print(result) // Prints Result.success
+ /// })
+ /// ```
///
/// - Parameter implementation: A closure implementation stub to evaluate.
/// - Returns: The current stubbing manager which can be used to chain additional stubs.
@@ -328,8 +358,10 @@ extension StubbingManager where DeclarationType == ThrowingFunctionDeclaration {
/// Stubbing allows you to define custom behavior for mocks to perform. Methods that throw or
/// rethrow errors can be stubbed with a throwable object.
///
- /// struct BirdError: Error {}
- /// given(bird.throwingMethod()).willThrow(BirdError())
+ /// ```swift
+ /// struct BirdError: Error {}
+ /// given(bird.throwingMethod()).willThrow(BirdError())
+ /// ```
///
/// - Note: Methods overloaded by return type should chain `returning` with `willThrow` to
/// disambiguate the mocked declaration.
@@ -346,15 +378,17 @@ extension StubbingManager where DeclarationType == ThrowingFunctionDeclaration {
/// Declarations for methods overloaded by return type and stubbed with `willThrow` cannot use
/// type inference and should be disambiguated.
///
- /// protocol Bird {
- /// func getMessage() throws -> T // Overloaded generically
- /// func getMessage() throws -> String // Overloaded explicitly
- /// func getMessage() throws -> Data
- /// }
+ /// ```swift
+ /// protocol Bird {
+ /// func getMessage() throws -> T // Overloaded generically
+ /// func getMessage() throws -> String // Overloaded explicitly
+ /// func getMessage() throws -> Data
+ /// }
///
- /// given(bird.send(any()))
- /// .returning(String.self)
- /// .willThrow(BirdError())
+ /// given(bird.send(any()))
+ /// .returning(String.self)
+ /// .willThrow(BirdError())
+ /// ```
///
/// - Parameter type: The return type of the declaration to stub.
public func returning(_ type: ReturnType.Type = ReturnType.self) -> Self {
@@ -368,8 +402,10 @@ extension StubbingManager where ReturnType == Void {
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
- /// given(bird.doVoidMethod()).willReturn()
- /// given(bird.setProperty(any())).willReturn()
+ /// ```swift
+ /// given(bird.doVoidMethod()).willReturn()
+ /// given(bird.setProperty(any())).willReturn()
+ /// ```
///
/// - Note: Methods returning `Void` do not need to be explicitly stubbed.
///
@@ -389,15 +425,19 @@ infix operator ~>
///
/// Stubbing allows you to define custom behavior for mocks to perform.
///
-/// given(bird.doMethod()) ~> someValue
-/// given(bird.property) ~> someValue
+/// ```swift
+/// given(bird.doMethod()) ~> someValue
+/// given(bird.property) ~> someValue
+/// ```
///
/// Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
/// later have a higher precedence, so add stubs with specific matchers last.
///
-/// given(bird.canChirp(volume: any())) ~> true // Any volume
-/// given(bird.canChirp(volume: notNil())) ~> true // Any non-nil volume
-/// given(bird.canChirp(volume: 10)) ~> true // Volume = 10
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> true // Any volume
+/// given(bird.canChirp(volume: notNil())) ~> true // Any non-nil volume
+/// given(bird.canChirp(volume: 10)) ~> true // Volume = 10
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -413,29 +453,33 @@ public func ~> (
///
/// Use a closure to implement stubs that contain logic, interact with arguments, or throw errors.
///
-/// given(bird.canChirp(volume: any())) ~> { volume in
-/// return volume < 42
-/// }
+/// ```swift
+/// given(bird.canChirp(volume: any())) ~> { volume in
+/// return volume < 42
+/// }
+/// ```
///
/// Stubs are type safe and work with inout and closure parameter types.
///
-/// protocol Bird {
-/// func send(_ message: inout String)
-/// func fly(callback: (Result) -> Void)
-/// }
-///
-/// // Inout parameter type
-/// var message = "Hello!"
-/// bird.send(&message)
-/// print(message) // Prints "HELLO!"
-///
-/// // Closure parameter type
-/// given(bird.fly(callback: any())).will { callback in
-/// callback(.success)
-/// }
-/// bird.fly(callback: { result in
-/// print(result) // Prints Result.success
-/// })
+/// ```swift
+/// protocol Bird {
+/// func send(_ message: inout String)
+/// func fly(callback: (Result) -> Void)
+/// }
+///
+/// // Inout parameter type
+/// var message = "Hello!"
+/// bird.send(&message)
+/// print(message) // Prints "HELLO!"
+///
+/// // Closure parameter type
+/// given(bird.fly(callback: any())).will { callback in
+/// callback(.success)
+/// }
+/// bird.fly(callback: { result in
+/// print(result) // Prints Result.success
+/// })
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -452,10 +496,12 @@ public func ~> (
/// There are several preset implementation providers such as `lastSetValue`, which can be used
/// with property getters to automatically save and return values.
///
-/// given(bird.name) ~> lastSetValue(initial: "")
-/// print(bird.name) // Prints ""
-/// bird.name = "Ryan"
-/// print(bird.name) // Prints "Ryan"
+/// ```swift
+/// given(bird.name) ~> lastSetValue(initial: "")
+/// print(bird.name) // Prints ""
+/// bird.name = "Ryan"
+/// print(bird.name) // Prints "Ryan"
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
@@ -471,13 +517,15 @@ public func ~> (
///
/// Use the stubbing operator to bind a specific mocked declaration to a forwarding context.
///
-/// class Crow {
-/// let name: String
-/// init(name: String) { self.name = name }
-/// }
+/// ```swift
+/// class Crow {
+/// let name: String
+/// init(name: String) { self.name = name }
+/// }
///
-/// given(bird.name) ~> forward(to: Crow(name: "Ryan"))
-/// print(bird.name) // Prints "Ryan"
+/// given(bird.name) ~> forward(to: Crow(name: "Ryan"))
+/// print(bird.name) // Prints "Ryan"
+/// ```
///
/// - Parameters:
/// - manager: A stubbing manager containing declaration and argument metadata for stubbing.
diff --git a/Sources/MockingbirdFramework/Stubbing/ValueProvider.swift b/Sources/MockingbirdFramework/Stubbing/ValueProvider.swift
index e3b5eb94..6efcb32e 100644
--- a/Sources/MockingbirdFramework/Stubbing/ValueProvider.swift
+++ b/Sources/MockingbirdFramework/Stubbing/ValueProvider.swift
@@ -12,23 +12,25 @@ import Foundation
/// Provide wildcard instances for generic types by conforming the base type to `Providable` and
/// registering the type. Non-wildcard instances have precedence over wildcard instances.
///
-/// extension Array: Providable {
-/// public static func createInstance() -> Self? {
-/// return Array()
-/// }
-/// }
+/// ```swift
+/// extension Array: Providable {
+/// public static func createInstance() -> Self? {
+/// return Array()
+/// }
+/// }
///
-/// var valueProvider = ValueProvider()
-/// valueProvider.registerType(Array.self)
+/// var valueProvider = ValueProvider()
+/// valueProvider.registerType(Array.self)
///
-/// // All specializations of `Array` return an empty array
-/// print(valueProvider.provideValue(for: Array.self)) // Prints []
-/// print(valueProvider.provideValue(for: Array.self)) // Prints []
+/// // All specializations of `Array` return an empty array
+/// print(valueProvider.provideValue(for: Array.self)) // Prints []
+/// print(valueProvider.provideValue(for: Array.self)) // Prints []
///
-/// // Register a non-wildcard instance of `Array`
-/// valueProvider.register(["A", "B"], for: Array.self)
-/// print(valueProvider.provideValue(for: Array.self)) // Prints ["A", "B"]
-/// print(valueProvider.provideValue(for: Array.self)) // Prints []
+/// // Register a non-wildcard instance of `Array`
+/// valueProvider.register(["A", "B"], for: Array.self)
+/// print(valueProvider.provideValue(for: Array.self)) // Prints ["A", "B"]
+/// print(valueProvider.provideValue(for: Array.self)) // Prints []
+/// ```
///
/// - Note: This can only be used for Swift types due to limitations with Objective-C generics in
/// Swift extensions.
@@ -56,17 +58,21 @@ extension Providable {
/// Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
/// such as `.standardProvider`.
///
-/// let bird = mock(Bird.self)
-/// bird.useDefaultValues(from: .standardProvider)
-/// print(bird.name) // Prints ""
+/// ```swift
+/// let bird = mock(Bird.self)
+/// bird.useDefaultValues(from: .standardProvider)
+/// print(bird.name) // Prints ""
+/// ```
///
/// You can create custom value providers by registering values for types.
///
-/// var valueProvider = ValueProvider()
-/// valueProvider.register("Ryan", for: String.self)
-///
-/// bird.useDefaultValues(from: valueProvider)
-/// print(bird.name) // Prints "Ryan"
+/// ```swift
+/// var valueProvider = ValueProvider()
+/// valueProvider.register("Ryan", for: String.self)
+///
+/// bird.useDefaultValues(from: valueProvider)
+/// print(bird.name) // Prints "Ryan"
+/// ```
public struct ValueProvider {
var storedValues = [ObjectIdentifier: Any]()
var enabledIdentifiers = Set()
@@ -92,9 +98,11 @@ public struct ValueProvider {
/// Value providers can be composed by adding values from another provider. Values in the other
/// provider have precedence and will overwrite existing values in this provider.
///
- /// var valueProvider = ValueProvider()
- /// valueProvider.add(.standardProvider)
- /// print(valueProvider.provideValue(for: String.self)) // Prints ""
+ /// ```swift
+ /// var valueProvider = ValueProvider()
+ /// valueProvider.add(.standardProvider)
+ /// print(valueProvider.provideValue(for: String.self)) // Prints ""
+ /// ```
///
/// - Parameter other: A value provider to combine.
mutating public func add(_ other: Self) {
@@ -107,9 +115,11 @@ public struct ValueProvider {
/// Value providers can be composed by adding values from another provider. Values in the added
/// provider have precendence over those in base provider.
///
- /// let valueProvider = ValueProvider.collectionsProvider.adding(.primitivesProvider)
- /// print(valueProvider.provideValue(for: [Bool].self)) // Prints []
- /// print(valueProvider.provideValue(for: Int.self)) // Prints 0
+ /// ```swift
+ /// let valueProvider = ValueProvider.collectionsProvider.adding(.primitivesProvider)
+ /// print(valueProvider.provideValue(for: [Bool].self)) // Prints []
+ /// print(valueProvider.provideValue(for: Int.self)) // Prints 0
+ /// ```
///
/// - Parameter other: A value provider to combine.
/// - Returns: A new value provider with the values of `lhs` and `rhs`.
@@ -124,9 +134,11 @@ public struct ValueProvider {
/// Value providers can be composed by adding values from other providers. Values in the second
/// provider have precendence over those in first provider.
///
- /// let valueProvider = .collectionsProvider + .primitivesProvider
- /// print(valueProvider.provideValue(for: [Bool].self)) // Prints []
- /// print(valueProvider.provideValue(for: Int.self)) // Prints 0
+ /// ```swift
+ /// let valueProvider = .collectionsProvider + .primitivesProvider
+ /// print(valueProvider.provideValue(for: [Bool].self)) // Prints []
+ /// print(valueProvider.provideValue(for: Int.self)) // Prints 0
+ /// ```
///
/// - Parameters:
/// - lhs: A value provider.
@@ -142,9 +154,11 @@ public struct ValueProvider {
///
/// Create custom value providers by registering values for types.
///
- /// var valueProvider = ValueProvider()
- /// valueProvider.register("Ryan", for: String.self)
- /// print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
+ /// ```swift
+ /// var valueProvider = ValueProvider()
+ /// valueProvider.register("Ryan", for: String.self)
+ /// print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
+ /// ```
///
/// - Parameters:
/// - value: The value to register.
@@ -159,23 +173,25 @@ public struct ValueProvider {
/// Provide wildcard instances for generic types by conforming the base type to `Providable` and
/// registering the type. Non-wildcard instances have precedence over wildcard instances.
///
- /// extension Array: Providable {
- /// public static func createInstance() -> Self? {
- /// return Array()
- /// }
- /// }
+ /// ```swift
+ /// extension Array: Providable {
+ /// public static func createInstance() -> Self? {
+ /// return Array()
+ /// }
+ /// }
///
- /// var valueProvider = ValueProvider()
- /// valueProvider.registerType(Array.self)
+ /// var valueProvider = ValueProvider()
+ /// valueProvider.registerType(Array.self)
///
- /// // All specializations of `Array` return an empty array
- /// print(valueProvider.provideValue(for: Array.self)) // Prints []
- /// print(valueProvider.provideValue(for: Array.self)) // Prints []
+ /// // All specializations of `Array` return an empty array
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints []
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints []
///
- /// // Register a non-wildcard instance of `Array`
- /// valueProvider.register(["A", "B"], for: Array.self)
- /// print(valueProvider.provideValue(for: Array.self)) // Prints ["A", "B"]
- /// print(valueProvider.provideValue(for: Array.self)) // Prints []
+ /// // Register a non-wildcard instance of `Array`
+ /// valueProvider.register(["A", "B"], for: Array.self)
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints ["A", "B"]
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints []
+ /// ```
///
/// - Parameter type: A `Providable` type to register.
mutating public func registerType(_ type: T.Type = T.self) {
@@ -187,16 +203,18 @@ public struct ValueProvider {
/// Previously registered values can be removed from the top-level value provider. This does not
/// affect values provided by subproviders.
///
- /// var valueProvider = ValueProvider(from: .standardProvider)
- /// print(valueProvider.provideValue(for: String.self)) // Prints ""
+ /// ```swift
+ /// var valueProvider = ValueProvider(from: .standardProvider)
+ /// print(valueProvider.provideValue(for: String.self)) // Prints ""
///
- /// // Override the subprovider value
- /// valueProvider.register("Ryan", for: String.self)
- /// print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
+ /// // Override the subprovider value
+ /// valueProvider.register("Ryan", for: String.self)
+ /// print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
///
- /// // Remove the registered value
- /// valueProvider.remove(String.self)
- /// print(valueProvider.provideValue(for: String.self)) // Prints ""
+ /// // Remove the registered value
+ /// valueProvider.remove(String.self)
+ /// print(valueProvider.provideValue(for: String.self)) // Prints ""
+ /// ```
///
/// - Parameter type: The type to remove a previously registered value for.
mutating public func remove(_ type: T.Type) {
@@ -208,13 +226,15 @@ public struct ValueProvider {
/// Previously registered wildcard instances for generic types can be removed from the top-level
/// value provider.
///
- /// var valueProvider = ValueProvider()
+ /// ```swift
+ /// var valueProvider = ValueProvider()
///
- /// valueProvider.registerType(Array.self)
- /// print(valueProvider.provideValue(for: Array.self)) // Prints []
+ /// valueProvider.registerType(Array.self)
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints []
///
- /// valueProvider.remove(Array.self)
- /// print(valueProvider.provideValue(for: Array.self)) // Prints nil
+ /// valueProvider.remove(Array.self)
+ /// print(valueProvider.provideValue(for: Array.self)) // Prints nil
+ /// ```
///
/// - Parameter type: A `Providable` type to remove.
mutating public func remove(_ type: T.Type = T.self) {
diff --git a/Sources/MockingbirdFramework/Verification/AsyncVerification.swift b/Sources/MockingbirdFramework/Verification/AsyncVerification.swift
index 5eee7dbd..dd433aa3 100644
--- a/Sources/MockingbirdFramework/Verification/AsyncVerification.swift
+++ b/Sources/MockingbirdFramework/Verification/AsyncVerification.swift
@@ -13,17 +13,19 @@ import XCTest
/// Mocked methods that are invoked asynchronously can be verified using an `eventually` block which
/// returns an `XCTestExpectation`.
///
-/// DispatchQueue.main.async {
-/// Tree(with: bird).shake()
-/// }
+/// ```swift
+/// DispatchQueue.main.async {
+/// Tree(with: bird).shake()
+/// }
///
-/// let expectation =
-/// eventually {
-/// verify(bird.fly()).wasCalled()
-/// verify(bird.chirp()).wasCalled()
-/// }
+/// let expectation =
+/// eventually {
+/// verify(bird.fly()).wasCalled()
+/// verify(bird.chirp()).wasCalled()
+/// }
///
-/// wait(for: [expectation], timeout: 1.0)
+/// wait(for: [expectation], timeout: 1.0)
+/// ```
///
/// - Parameters:
/// - description: An optional description for the created `XCTestExpectation`.
diff --git a/Sources/MockingbirdFramework/Verification/OrderedVerification.swift b/Sources/MockingbirdFramework/Verification/OrderedVerification.swift
index f2af5519..b4b83fc3 100644
--- a/Sources/MockingbirdFramework/Verification/OrderedVerification.swift
+++ b/Sources/MockingbirdFramework/Verification/OrderedVerification.swift
@@ -13,38 +13,44 @@ import XCTest
/// Calls to `verify` within the scope of an `inOrder` verification block are checked relative to
/// each other.
///
-/// // Verify that `canFly` was called before `fly`
-/// inOrder {
-/// verify(bird.canFly).wasCalled()
-/// verify(bird.fly()).wasCalled()
-/// }
+/// ```swift
+/// // Verify that `canFly` was called before `fly`
+/// inOrder {
+/// verify(bird.canFly).wasCalled()
+/// verify(bird.fly()).wasCalled()
+/// }
+/// ```
///
/// Pass options to `inOrder` verification blocks for stricter checks with additional invariants.
///
-/// inOrder(with: .noInvocationsAfter) {
-/// verify(bird.canFly).wasCalled()
-/// verify(bird.fly()).wasCalled()
-/// }
+/// ```swift
+/// inOrder(with: .noInvocationsAfter) {
+/// verify(bird.canFly).wasCalled()
+/// verify(bird.fly()).wasCalled()
+/// }
+/// ```
///
/// An `inOrder` block is resolved greedily, such that each verification must happen from the oldest
/// remaining unsatisfied invocations.
///
-/// // Given these unsatisfied invocations
-/// bird.canFly
-/// bird.canFly
-/// bird.fly()
+/// ```swift
+/// // Given these unsatisfied invocations
+/// bird.canFly
+/// bird.canFly
+/// bird.fly()
///
-/// // Greedy strategy _must_ start from the first `canFly`
-/// inOrder {
-/// verify(bird.canFly).wasCalled(twice)
-/// verify(bird.fly()).wasCalled()
-/// }
+/// // Greedy strategy _must_ start from the first `canFly`
+/// inOrder {
+/// verify(bird.canFly).wasCalled(twice)
+/// verify(bird.fly()).wasCalled()
+/// }
///
-/// // Non-greedy strategy can start from the second `canFly`
-/// inOrder {
-/// verify(bird.canFly).wasCalled()
-/// verify(bird.fly()).wasCalled()
-/// }
+/// // Non-greedy strategy can start from the second `canFly`
+/// inOrder {
+/// verify(bird.canFly).wasCalled()
+/// verify(bird.fly()).wasCalled()
+/// }
+/// ```
///
/// - Parameters:
/// - options: Options to use when verifying invocations.
@@ -66,63 +72,69 @@ public struct OrderedVerificationOptions: OptionSet {
///
/// Use this option to disallow invocations prior to those satisfying the first verification.
///
- /// bird.name
- /// bird.canFly
- /// bird.fly()
+ /// ```swift
+ /// bird.name
+ /// bird.canFly
+ /// bird.fly()
///
- /// // Passes _without_ the option
- /// inOrder {
- /// verify(bird.canFly).wasCalled()
- /// verify(bird.fly()).wasCalled()
- /// }
+ /// // Passes _without_ the option
+ /// inOrder {
+ /// verify(bird.canFly).wasCalled()
+ /// verify(bird.fly()).wasCalled()
+ /// }
///
- /// // Fails with the option
- /// inOrder(with: .noInvocationsBefore) {
- /// verify(bird.canFly).wasCalled()
- /// verify(bird.fly()).wasCalled()
- /// }
+ /// // Fails with the option
+ /// inOrder(with: .noInvocationsBefore) {
+ /// verify(bird.canFly).wasCalled()
+ /// verify(bird.fly()).wasCalled()
+ /// }
+ /// ```
public static let noInvocationsBefore = OrderedVerificationOptions(rawValue: 1 << 0)
/// Check that there are no recorded invocations after those explicitly verified in the block.
///
/// Use this option to disallow subsequent invocations to those satisfying the last verification.
///
- /// bird.name
- /// bird.canFly
- /// bird.fly()
+ /// ```swift
+ /// bird.name
+ /// bird.canFly
+ /// bird.fly()
///
- /// // Passes _without_ the option
- /// inOrder {
- /// verify(bird.name).wasCalled()
- /// verify(bird.canFly).wasCalled()
- /// }
+ /// // Passes _without_ the option
+ /// inOrder {
+ /// verify(bird.name).wasCalled()
+ /// verify(bird.canFly).wasCalled()
+ /// }
///
- /// // Fails with the option
- /// inOrder(with: .noInvocationsAfter) {
- /// verify(bird.name).wasCalled()
- /// verify(bird.canFly).wasCalled()
- /// }
+ /// // Fails with the option
+ /// inOrder(with: .noInvocationsAfter) {
+ /// verify(bird.name).wasCalled()
+ /// verify(bird.canFly).wasCalled()
+ /// }
+ /// ```
public static let noInvocationsAfter = OrderedVerificationOptions(rawValue: 1 << 1)
/// Check that there are no recorded invocations between those explicitly verified in the block.
///
/// Use this option to disallow non-consecutive invocations to each verification.
///
- /// bird.name
- /// bird.canFly
- /// bird.fly()
+ /// ```swift
+ /// bird.name
+ /// bird.canFly
+ /// bird.fly()
///
- /// // Passes _without_ the option
- /// inOrder {
- /// verify(bird.name).wasCalled()
- /// verify(bird.fly()).wasCalled()
- /// }
+ /// // Passes _without_ the option
+ /// inOrder {
+ /// verify(bird.name).wasCalled()
+ /// verify(bird.fly()).wasCalled()
+ /// }
///
- /// // Fails with the option
- /// inOrder(with: .onlyConsecutiveInvocations) {
- /// verify(bird.name).wasCalled()
- /// verify(bird.fly()).wasCalled()
- /// }
+ /// // Fails with the option
+ /// inOrder(with: .onlyConsecutiveInvocations) {
+ /// verify(bird.name).wasCalled()
+ /// verify(bird.fly()).wasCalled()
+ /// }
+ /// ```
public static let onlyConsecutiveInvocations = OrderedVerificationOptions(rawValue: 1 << 2)
}
diff --git a/Sources/MockingbirdFramework/Verification/Verification.swift b/Sources/MockingbirdFramework/Verification/Verification.swift
index 763d1e3d..5e4c6363 100644
--- a/Sources/MockingbirdFramework/Verification/Verification.swift
+++ b/Sources/MockingbirdFramework/Verification/Verification.swift
@@ -8,19 +8,23 @@
import Foundation
import XCTest
-/// Verify that a mock recieved a specific invocation some number of times.
+/// Verify that a declaration was called.
///
/// Verification lets you assert that a mock received a particular invocation during its lifetime.
///
-/// verify(bird.doMethod()).wasCalled()
-/// verify(bird.getProperty()).wasCalled()
-/// verify(bird.setProperty(any())).wasCalled()
+/// ```swift
+/// verify(bird.doMethod()).wasCalled()
+/// verify(bird.getProperty()).wasCalled()
+/// verify(bird.setProperty(any())).wasCalled()
+/// ```
///
/// Match exact or wildcard argument values when verifying methods with parameters.
///
-/// verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-/// verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-/// verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
+/// ```swift
+/// verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
+/// verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
+/// verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
+/// ```
///
/// - Parameters:
/// - mock: A mocked declaration to verify.
@@ -31,19 +35,23 @@ public func verify(
return VerificationManager(with: declaration, at: SourceLocation(file, line))
}
-/// Verify that a mock recieved a specific invocation some number of times.
+/// Verify that an Objective-C mock or property declaration was called.
///
/// Verification lets you assert that a mock received a particular invocation during its lifetime.
///
-/// verify(bird.doMethod()).wasCalled()
-/// verify(bird.getProperty()).wasCalled()
-/// verify(bird.setProperty(any())).wasCalled()
+/// ```swift
+/// verify(bird.doMethod()).wasCalled()
+/// verify(bird.getProperty()).wasCalled()
+/// verify(bird.setProperty(any())).wasCalled()
+/// ```
///
/// Match exact or wildcard argument values when verifying methods with parameters.
///
-/// verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-/// verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-/// verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
+/// ```swift
+/// verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
+/// verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
+/// verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
+/// ```
///
/// - Parameters:
/// - mock: A mocked declaration to verify.
@@ -114,15 +122,17 @@ public class VerificationManager {
/// Declarations for methods overloaded by return type cannot type inference and should be
/// disambiguated.
///
- /// protocol Bird {
- /// func getMessage() throws -> T // Overloaded generically
- /// func getMessage() throws -> String // Overloaded explicitly
- /// func getMessage() throws -> Data
- /// }
+ /// ```swift
+ /// protocol Bird {
+ /// func getMessage() throws -> T // Overloaded generically
+ /// func getMessage() throws -> String // Overloaded explicitly
+ /// func getMessage() throws -> Data
+ /// }
///
- /// verify(bird.send(any()))
- /// .returning(String.self)
- /// .wasCalled()
+ /// verify(bird.send(any()))
+ /// .returning(String.self)
+ /// .wasCalled()
+ /// ```
///
/// - Parameter type: The return type of the declaration to verify.
public func returning(_ type: ReturnType.Type = ReturnType.self) -> Self {
From 850bb734cebfc9752a5a532ab177074ee872e968 Mon Sep 17 00:00:00 2001
From: Andrew Chang
Date: Thu, 30 Dec 2021 19:36:11 -1000
Subject: [PATCH 02/20] Remove versioned README
---
README-0.19.md | 824 -------------------------------------------------
README.md | 199 +++++++-----
2 files changed, 121 insertions(+), 902 deletions(-)
delete mode 100644 README-0.19.md
diff --git a/README-0.19.md b/README-0.19.md
deleted file mode 100644
index f4149416..00000000
--- a/README-0.19.md
+++ /dev/null
@@ -1,824 +0,0 @@
-
-
-
Mockingbird
-
-
-
-
-
-
-
-
-Mockingbird lets you mock, stub, and verify objects written in either Swift or Objective-C. The syntax takes inspiration from (OC)Mockito but was designed to be “Swifty” in terms of type safety and expressiveness.
-
-```swift
-// Mocking
-let bird = mock(Bird.self)
-
-// Stubbing
-given(bird.name).willReturn("Ryan")
-
-// Verification
-verify(bird.fly()).wasCalled()
-```
-
-Mockingbird was built to reduce the number of “artisanal” hand-written mocks and make it easier to write tests at Bird. Conceptually, Mockingbird uses codegen to statically mock Swift types and `NSProxy` to dynamically mock Objective-C types. The approach is similar to other automatic Swift mocking frameworks and is unlikely to change due to Swift’s limited runtime introspection capabilities.
-
-That said, there are a few key differences from other frameworks:
-
-- Generating mocks takes seconds instead of minutes on large codebases with thousands of mocked types.
-- Stubbing and verification failures appear inline and don’t abort the entire test run.
-- Production code is kept separate from tests and never modified with annotations.
-- Xcode projects can be used as the source of truth to automatically determine source files.
-
-See a detailed [feature comparison table](https://github.com/birdrides/mockingbird/wiki/Alternatives-to-Mockingbird#feature-comparison) and [known limitations](https://github.com/birdrides/mockingbird/wiki/Known-Limitations).
-
-### Who Uses Mockingbird?
-
-Mockingbird powers thousands of tests at companies including [Meta](https://meta.com), [Amazon](https://amazon.com), [Twilio](https://twilio.com), and [Bird](https://bird.co). Using Mockingbird to improve your testing workflow? Consider dropping us a line on the [#mockingbird Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw).
-
-### An Example
-
-Let’s say we wanted to test a `Person` class with a method that takes a `Bird`.
-
-```swift
-protocol Bird {
- var canFly: Bool { get }
- func fly()
-}
-
-class Person {
- func release(_ bird: Bird) {
- guard bird.canFly else { return }
- bird.fly()
- }
-}
-```
-
-With Mockingbird, it’s easy to stub return values and verify that mocked methods were called.
-
-```swift
-// Given a bird that can fly
-let bird = mock(Bird.self)
-given(bird.canFly).willReturn(true)
-
-// When a person releases the bird
-Person().release(bird)
-
-// Then the bird flies away
-verify(bird.fly()).wasCalled()
-```
-
-## Quick Start
-
-Select your preferred dependency manager below to get started.
-
-CocoaPods
-
-Add the framework to a test target in your `Podfile`, making sure to include the `use_frameworks!` option.
-
-```ruby
-target 'MyAppTests' do
- use_frameworks!
- pod 'MockingbirdFramework', '~> 0.19'
-end
-```
-
-In your project directory, initialize the pod.
-
-```console
-$ pod install
-```
-
-Finally, configure the test target to generate mocks for specific modules or libraries.
-
-> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
-
-```console
-$ Pods/MockingbirdFramework/mockingbird configure MyAppTests -- --targets MyApp MyLibrary1 MyLibrary2
-```
-
-Optional but recommended:
-
-- [Exclude generated files from source control](https://github.com/birdrides/mockingbird/wiki/Integration-Tips#source-control-exclusion)
-- [Add supporting source files for compatibility with external dependencies](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files)
-
-Have questions or issues?
-
-- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
-- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the CocoaPods example project](/Examples/CocoaPodsExample)
-
-
-
-Carthage
-
-Add the framework to your `Cartfile`.
-
-```
-github "birdrides/mockingbird" ~> 0.19
-```
-
-In your project directory, build the framework and [link it to your test target](https://github.com/birdrides/mockingbird/wiki/Linking-Test-Targets).
-
-```console
-$ carthage update --use-xcframeworks
-```
-
-Finally, configure the test target to generate mocks for specific modules or libraries.
-
-> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
-
-```console
-$ Carthage/Checkouts/mockingbird/mockingbird configure MyAppTests -- --targets MyApp MyLibrary1 MyLibrary2
-```
-
-Optional but recommended:
-
-- [Exclude generated files from source control](https://github.com/birdrides/mockingbird/wiki/Integration-Tips#source-control-exclusion)
-- [Add supporting source files for compatibility with external dependencies](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files)
-
-Have questions or issues?
-
-- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
-- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the Carthage example project](/Examples/CarthageExample)
-
-
-
-SwiftPM - Xcode Project
-
-Add the framework to your project:
-
-1. Navigate to **File › Add Packages…** and enter `https://github.com/birdrides/mockingbird`
-2. Change **Dependency Rule** to “Up to Next Minor Version” and enter `0.19.0`
-3. Click **Add Package**
-4. Select your test target and click **Add Package**
-
-In your project directory, resolve the derived data path. This can take a few moments.
-
-```console
-$ DERIVED_DATA="$(xcodebuild -showBuildSettings | sed -n 's|.*BUILD_ROOT = \(.*\)/Build/.*|\1|p'
-```
-
-Finally, configure the test target to generate mocks for specific modules or libraries.
-
-> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
-
-```console
-$ "${DERIVED_DATA}/SourcePackages/checkouts/mockingbird/mockingbird" configure MyPackageTests -- --targets MyPackage MyLibrary1 MyLibrary2
-```
-
-Optional but recommended:
-
-- [Exclude generated files from source control](https://github.com/birdrides/mockingbird/wiki/Integration-Tips#source-control-exclusion)
-- [Add supporting source files for compatibility with external dependencies](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files)
-
-Have questions or issues?
-
-- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
-- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the SwiftPM Xcode project example](/Examples/SPMProjectExample)
-
-
-
-SwiftPM - Package Manifest
-
-Add Mockingbird as a package and test target dependency in your `Package.swift` manifest.
-
-```swift
-let package = Package(
- name: "MyPackage",
- dependencies: [
- .package(name: "Mockingbird", url: "https://github.com/birdrides/mockingbird.git", .upToNextMinor(from: "0.19.0")),
- ],
- targets: [
- .testTarget(name: "MyPackageTests", dependencies: ["Mockingbird"]),
- ]
-)
-```
-
-In your package directory, initialize the dependency.
-
-```console
-$ swift package update Mockingbird
-```
-
-Next, create a Bash script named `gen-mocks.sh` in the same directory as your package manifest. Copy the example below, making sure to change the lines marked with `FIXME`.
-
-```bash
-#!/bin/bash
-set -eu
-cd "$(dirname "$0")"
-swift package describe --type json > project.json
-.build/checkouts/mockingbird/mockingbird generate --project project.json \
- --output-dir Sources/MyPackageTests/MockingbirdMocks \ # FIXME: Where mocks should be generated.
- --testbundle MyPackageTests \ # FIXME: Name of your test target.
- --targets MyPackage MyLibrary1 MyLibrary2 # FIXME: Specific modules or libraries that should be mocked.
-```
-
-Ensure that the script runs and generates mock files.
-
-```console
-$ chmod u+x gen-mocks.sh
-$ ./gen-mocks.sh
-Generated file to MockingbirdMocks/MyPackageTests-MyPackage.generated.swift
-Generated file to MockingbirdMocks/MyPackageTests-MyLibrary1.generated.swift
-Generated file to MockingbirdMocks/MyPackageTests-MyLibrary2.generated.swift
-```
-
-Finally, add each generated mock file to your test target sources.
-
-```swift
-.testTarget(
- name: "MyPackageTests",
- dependencies: ["Mockingbird"],
- sources: [
- "Tests/MyPackageTests",
- "MockingbirdMocks/MyPackageTests-MyPackage.generated.swift",
- "MockingbirdMocks/MyPackageTests-MyLibrary1.generated.swift",
- "MockingbirdMocks/MyPackageTests-MyLibrary2.generated.swift",
- ]),
-```
-
-Optional but recommended:
-
-- [Exclude generated files from source control](https://github.com/birdrides/mockingbird/wiki/Integration-Tips#source-control-exclusion)
-- [Add supporting source files for compatibility with external dependencies](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files)
-
-Have questions or issues?
-
-- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
-- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the SwiftPM package manifest example](/Examples/SPMPackageExample)
-
-
-
-## Usage
-
-Mockingbird provides a comprehensive [API reference](https://birdrides.github.io/mockingbird/latest/) generated with [SwiftDoc](https://github.com/SwiftDocOrg/swift-doc).
-
-1. [Mocking](#1-mocking)
-2. [Stubbing](#2-stubbing)
-3. [Verification](#3-verification)
-4. [Argument Matching](#4-argument-matching)
-5. [Advanced Topics](#5-advanced-topics)
-
-### 1. Mocking
-
-Mocks can be passed as instances of the original type, recording any calls they receive for later verification. Note that mocks are strict by default, meaning that calls to unstubbed non-void methods will trigger a test failure. To create a relaxed or “loose” mock, use a [default value provider](#stub-as-a-relaxed-mock).
-
-```swift
-// Swift types
-let protocolMock = mock(MyProtocol.self)
-let classMock = mock(MyClass.self).initialize(…)
-
-// Objective-C types
-let protocolMock = mock(MyProtocol.self)
-let classMock = mock(MyClass.self)
-```
-
-#### Mock Swift Classes
-
-Swift class mocks rely on subclassing the original type which comes with a few [known limitations](https://github.com/birdrides/mockingbird/wiki/Known-Limitations). When creating a Swift class mock, you must initialize the instance by calling `initialize(…)` with appropriate values.
-
-```swift
-class Tree {
- init(height: Int) { assert(height > 0) }
-}
-
-let tree = mock(Tree.self).initialize(height: 42) // Initialized
-let tree = mock(Tree.self).initialize(height: 0) // Assertion failed (height ≤ 0)
-```
-
-#### Store Mocks
-
-Generated Swift mock types are suffixed with `Mock`. Avoid coercing mocks into their original type as stubbing and verification will no longer work.
-
-```swift
-// Good
-let bird: BirdMock = mock(Bird.self) // Concrete type is `BirdMock`
-let bird = mock(Bird.self) // Inferred type is `BirdMock`
-
-// Avoid
-let bird: Bird = mock(Bird.self) // Type is coerced into `Bird`
-```
-
-#### Reset Mocks
-
-You can reset mocks and clear specific metadata during test runs. However, resetting mocks isn’t usually necessary in well-constructed tests.
-
-```swift
-reset(bird) // Reset everything
-clearStubs(on: bird) // Only remove stubs
-clearInvocations(on: bird) // Only remove recorded invocations
-```
-
-### 2. Stubbing
-
-Stubbing allows you to define custom behavior for mocks to perform.
-
-```swift
-given(bird.name).willReturn("Ryan") // Return a value
-given(bird.chirp()).willThrow(BirdError()) // Throw an error
-given(bird.chirp(volume: any())).will { volume in // Call a closure
- return volume < 42
-}
-```
-
-This is equivalent to the shorthand syntax using the stubbing operator `~>`.
-
-```swift
-given(bird.name) ~> "Ryan" // Return a value
-given(bird.chirp()) ~> { throw BirdError() } // Throw an error
-given(bird.chirp(volume: any())) ~> { volume in // Call a closure
- return volume < 42
-}
-```
-
-#### Stub Methods with Parameters
-
-[Match argument values](#4-argument-matching) to stub parameterized methods. Stubs added later have a higher precedence, so add stubs with specific matchers last.
-
-```swift
-given(bird.chirp(volume: any())).willReturn(true) // Any volume
-given(bird.chirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.chirp(volume: 10)).willReturn(true) // Volume = 10
-```
-
-#### Stub Properties
-
-Properties can have stubs on both their getters and setters.
-
-```swift
-given(bird.name).willReturn("Ryan")
-given(bird.name = any()).will { (name: String) in
- print("Hello \(name)")
-}
-
-print(bird.name) // Prints "Ryan"
-bird.name = "Sterling" // Prints "Hello Sterling"
-```
-
-This is equivalent to using the synthesized getter and setter methods.
-
-```swift
-given(bird.getName()).willReturn("Ryan")
-given(bird.setName(any())).will { (name: String) in
- print("Hello \(name)")
-}
-
-print(bird.name) // Prints "Ryan"
-bird.name = "Sterling" // Prints "Hello Sterling"
-```
-
-Readwrite properties can be stubbed to automatically save and return values.
-
-```swift
-given(bird.name).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-```
-
-#### Stub as a Relaxed Mock
-
-Use a `ValueProvider` to create a relaxed mock that returns default values for unstubbed methods. Mockingbird provides preset value providers which are guaranteed to be backwards compatible, such as `.standardProvider`.
-
-```swift
-let bird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-```
-
-You can create custom value providers by registering values for specific types.
-
-```swift
-var valueProvider = ValueProvider()
-valueProvider.register("Ryan", for: String.self)
-bird.useDefaultValues(from: valueProvider)
-print(bird.name) // Prints "Ryan"
-```
-
-Values from concrete stubs always have a higher precedence than default values.
-
-```swift
-given(bird.name).willReturn("Ryan")
-print(bird.name) // Prints "Ryan"
-
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints "Ryan"
-```
-
-Provide wildcard instances for generic types by conforming the base type to `Providable` and registering the type.
-
-```swift
-extension Array: Providable {
- public static func createInstance() -> Self? {
- return Array()
- }
-}
-
-// Provide an empty array for all specialized `Array` types
-valueProvider.registerType(Array.self)
-```
-
-#### Stub as a Partial Mock
-
-Partial mocks can be created by forwarding all calls to a specific object. Forwarding targets are strongly referenced and receive invocations until removed with `clearStubs`.
-
-```swift
-class Crow: Bird {
- let name: String
- init(name: String) { self.name = name }
-}
-
-let bird = mock(Bird.self)
-bird.forwardCalls(to: Crow(name: "Ryan"))
-print(bird.name) // Prints "Ryan"
-```
-
-Swift class mocks can also forward invocations to its underlying superclass.
-
-```swift
-let tree = mock(Tree.self).initialize(height: 42)
-tree.forwardCallsToSuper()
-print(tree.height) // Prints "42"
-```
-
-For more granular stubbing, it’s possible to scope both object and superclass forwarding targets to a specific declaration.
-
-```swift
-given(bird.name).willForward(to: Crow(name: "Ryan")) // Object target
-given(tree.height).willForwardToSuper() // Superclass target
-```
-
-Concrete stubs always have a higher priority than forwarding targets, regardless of the order
-they were added.
-
-```swift
-given(bird.name).willReturn("Ryan")
-given(bird.name).willForward(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Ryan"
-```
-
-#### Stub a Sequence of Values
-
-Methods that return a different value each time can be stubbed with a sequence of values. The last value will be used for all subsequent invocations.
-
-```swift
-given(bird.name).willReturn(sequence(of: "Ryan", "Sterling"))
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-```
-
-It’s also possible to stub a sequence of arbitrary behaviors.
-
-```swift
-given(bird.name)
- .willReturn("Ryan")
- .willReturn("Sterling")
- .will { return Bool.random() ? "Ryan" : "Sterling" }
-```
-
-### 3. Verification
-
-Verification lets you assert that a mock received a particular invocation during its lifetime.
-
-```swift
-verify(bird.fly()).wasCalled()
-```
-
-Verifying doesn’t remove recorded invocations, so it’s safe to call `verify` multiple times.
-
-```swift
-verify(bird.fly()).wasCalled() // If this succeeds...
-verify(bird.fly()).wasCalled() // ...this also succeeds
-```
-
-#### Verify Methods with Parameters
-
-[Match argument values](#4-argument-matching) to verify methods with parameters.
-
-```swift
-verify(bird.chirp(volume: any())).wasCalled() // Any volume
-verify(bird.chirp(volume: notNil())).wasCalled() // Any non-nil volume
-verify(bird.chirp(volume: 10)).wasCalled() // Volume = 10
-```
-
-#### Verify Properties
-
-Verify property invocations using their getter and setter methods.
-
-```swift
-verify(bird.name).wasCalled()
-verify(bird.name = any()).wasCalled()
-```
-
-#### Verify the Number of Invocations
-
-It’s possible to verify that an invocation was called a specific number of times with a count matcher.
-
-```swift
-verify(bird.fly()).wasNeverCalled() // n = 0
-verify(bird.fly()).wasCalled(exactly(10)) // n = 10
-verify(bird.fly()).wasCalled(atLeast(10)) // n ≥ 10
-verify(bird.fly()).wasCalled(atMost(10)) // n ≤ 10
-verify(bird.fly()).wasCalled(between(5...10)) // 5 ≤ n ≤ 10
-```
-
-Count matchers also support chaining and negation using logical operators.
-
-```swift
-verify(bird.fly()).wasCalled(not(exactly(10))) // n ≠ 10
-verify(bird.fly()).wasCalled(exactly(10).or(atMost(5))) // n = 10 || n ≤ 5
-```
-
-#### Capture Argument Values
-
-An argument captor extracts received argument values which can be used in other parts of the test.
-
-```swift
-let bird = mock(Bird.self)
-bird.name = "Ryan"
-
-let nameCaptor = ArgumentCaptor()
-verify(bird.name = nameCaptor.any()).wasCalled()
-
-print(nameCaptor.value) // Prints "Ryan"
-```
-
-#### Verify Invocation Order
-
-Enforce the relative order of invocations with an `inOrder` verification block.
-
-```swift
-// Verify that `canFly` was called before `fly`
-inOrder {
- verify(bird.canFly).wasCalled()
- verify(bird.fly()).wasCalled()
-}
-```
-
-Pass options to `inOrder` verification blocks for stricter checks with additional invariants.
-
-```swift
-inOrder(with: .noInvocationsAfter) {
- verify(bird.canFly).wasCalled()
- verify(bird.fly()).wasCalled()
-}
-```
-
-#### Verify Asynchronous Calls
-
-Mocked methods that are invoked asynchronously can be verified using an `eventually` block which returns an `XCTestExpectation`.
-
-```swift
-DispatchQueue.main.async {
- guard bird.canFly else { return }
- bird.fly()
-}
-
-let expectation =
- eventually {
- verify(bird.canFly).wasCalled()
- verify(bird.fly()).wasCalled()
- }
-
-wait(for: [expectation], timeout: 1.0)
-```
-
-#### Verify Overloaded Methods
-
-Use the `returning` modifier to disambiguate methods overloaded by return type. Methods overloaded by parameter types do not require disambiguation.
-
-```swift
-protocol Bird {
- func getMessage() -> T // Overloaded generically
- func getMessage() -> String // Overloaded explicitly
- func getMessage() -> Data
-}
-
-verify(bird.getMessage()).returning(String.self).wasCalled()
-```
-
-### 4. Argument Matching
-
-Argument matching allows you to stub or verify specific invocations of parameterized methods.
-
-#### Match Exact Values
-
-Types that explicitly conform to `Equatable` work out of the box, such as `String`.
-
-```swift
-given(bird.chirp(volume: 42)).willReturn(true)
-print(bird.chirp(volume: 42)) // Prints "true"
-verify(bird.chirp(volume: 42)).wasCalled() // Passes
-```
-
-Structs able to synthesize `Equatable` conformance must explicitly declare conformance to enable exact argument matching.
-
-```swift
-struct Fruit: Equatable {
- let size: Int
-}
-
-bird.eat(Fruit(size: 42))
-verify(bird.eat(Fruit(size: 42))).wasCalled()
-```
-
-Non-equatable classes are compared by reference instead.
-
-```swift
-class Fruit {}
-let fruit = Fruit()
-
-bird.eat(fruit)
-verify(bird.eat(fruit)).wasCalled()
-```
-
-#### Match Wildcard Values and Non-Equatable Types
-
-Argument matchers allow for wildcard or custom matching of arguments that are not `Equatable`.
-
-```swift
-any() // Any value
-any(of: 1, 2, 3) // Any value in {1, 2, 3}
-any(where: { $0 > 42 }) // Any number greater than 42
-notNil() // Any non-nil value
-```
-
-For methods overloaded by parameter type, you should help the compiler by specifying an explicit type in the matcher.
-
-```swift
-any(Int.self)
-any(Int.self, of: 1, 2, 3)
-any(Int.self, where: { $0 > 42 })
-notNil(String?.self)
-```
-
-You can also match elements or keys within collection types.
-
-```swift
-any(containing: 1, 2, 3) // Any collection with values {1, 2, 3}
-any(keys: "a", "b", "c") // Any dictionary with keys {"a", "b", "c"}
-any(count: atMost(42)) // Any collection with at most 42 elements
-notEmpty() // Any non-empty collection
-```
-
-#### Match Value Types in Objective-C
-
-You must specify an argument position when matching an Objective-C method with multiple value type parameters. Mockingbird will raise a test failure if the argument position is not inferrable and no explicit position was provided.
-
-```swift
-@objc class Bird: NSObject {
- @objc dynamic func chirp(volume: Int, duration: Int) {}
-}
-
-verify(bird.chirp(volume: firstArg(any()),
- duration: secondArg(any())).wasCalled()
-
-// Equivalent verbose syntax
-verify(bird.chirp(volume: arg(any(), at: 1),
- duration: arg(any(), at: 2)).wasCalled()
-```
-
-#### Match Floating Point Values
-
-Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
-
-```swift
-around(10.0, tolerance: 0.01)
-```
-
-### 5. Advanced Topics
-
-#### Excluding Files
-
-You can exclude unwanted or problematic sources from being mocked by adding a `.mockingbird-ignore` file. Mockingbird follows the same pattern format as [`.gitignore`](https://git-scm.com/docs/gitignore#_pattern_format) and scopes ignore files to their enclosing directory.
-
-#### Using Supporting Source Files
-
-Supporting source files are used by the generator to resolve inherited types defined outside of your project. Although Mockingbird provides a preset “starter pack” for basic compatibility with common system frameworks, you will occasionally need to add your own definitions for third-party library types. Please see [Supporting Source Files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files) for more information.
-
-#### Thunk Pruning
-
-To improve compilation times for large projects, Mockingbird only generates mocking code (known as thunks) for types used in tests. Unused types can either produce “thunk stubs” or no code at all depending on the pruning level specified.
-
-| Level | Description |
-| --- | --- |
-| `disable` | Always generate full thunks regardless of usage in tests. |
-| `stub` | Generate partial definitions filled with `fatalError`. |
-| `omit` | Don’t generate any definitions for unused types. |
-
-Usage is determined by statically analyzing test target sources for calls to `mock(SomeType.self)`, which may not work out of the box for projects that indirectly synthesize types such as through Objective-C based dependency injection.
-
-- **Option 1:** Explicitly reference each indirectly synthesized type in your tests, e.g. `_ = mock(SomeType.self)`. References can be placed anywhere in the test target sources, such as in the `setUp` method of a test case or in a single file.
-- **Option 2:** Disable pruning entirely by setting the prune level with `--prune disable`. Note that this may increase compilation times for large projects.
-
-## Mockingbird CLI
-
-### Generate
-
-Generate mocks for a set of targets in a project.
-
-`mockingbird generate`
-
-| Option | Default Value | Description |
-| --- | --- | --- |
-| `-t, --targets` | *(required)* | List of target names to generate mocks for. |
-| `-o, --outputs` | [`(inferred)`](#--outputs) | List of output file paths corresponding to each target. |
-| `-p, --project` | [`(inferred)`](#--project) | Path to an Xcode project or a [JSON project description](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects). |
-| `--output-dir` | [`(inferred)`](#--outputs) | The directory where generated files should be output. |
-| `--srcroot` | [`(inferred)`](#--srcroot) | The directory containing your project’s source files. |
-| `--support` | [`(inferred)`](#--support) | The directory containing [supporting source files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files). |
-| `--testbundle` | [`(inferred)`](#--testbundle) | The name of the test bundle using the mocks. |
-| `--header` | `(none)` | Content to add at the beginning of each generated mock file. |
-| `--condition` | `(none)` | [Compilation condition](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID538) to wrap all generated mocks in, e.g. `DEBUG`. |
-| `--diagnostics` | `(none)` | List of [diagnostic generator warnings](https://github.com/birdrides/mockingbird/wiki/Diagnostic-Warnings-and-Errors) to enable. |
-| `--prune` | `omit` | The [pruning method](#thunk-pruning) to use on unreferenced types. |
-
-| Flag | Description |
-| --- | --- |
-| `--only-protocols` | Only generate mocks for protocols. |
-| `--disable-swiftlint` | Disable all SwiftLint rules in generated mocks. |
-| `--disable-cache` | Ignore cached mock information stored on disk. |
-| `--disable-relaxed-linking` | Only search explicitly imported modules. |
-
-### Configure
-
-Configure a test target to generate mocks.
-
-`mockingbird configure -- `
-
-| Argument | Description |
-| --- | --- |
-| `test-target` | The name of a test target to configure. |
-| `generator-options` | Arguments to use when running the generator. See the 'generate' command for all options. |
-
-| Option | Default Value | Description |
-| --- | --- | --- |
-| `-p, --project` | [`(inferred)`](#--project) | Path to an Xcode project. |
-| `--srcproject` | [`(inferred)`](#--project) | Path to the Xcode project with source modules, if separate from tests. |
-| `--generator` | [`(inferred)`](#--generator) | Path to the Mockingbird generator executable. |
-| `--url` | [`(inferred)`](#--url) | The base URL hosting downloadable asset bundles. |
-
-| Flag | Description |
-| --- | --- |
-| `--preserve-existing` | Keep previously added Mockingbird build phases. |
-
-### Global Options
-
-| Flag | Description |
-| --- | --- |
-| `--verbose` | Log all errors, warnings, and debug messages. |
-| `--quiet` | Only log error messages. |
-| `--version` | Show the version. |
-| `-h, --help` | Show help information. |
-
-### Default Inferred Values
-
-#### `--project`
-
-Mockingbird first checks the environment variable `PROJECT_FILE_PATH` set by the Xcode build context and then performs a shallow search of the current working directory for an `.xcodeproj` file. If multiple `.xcodeproj` files exist then you must explicitly provide a project file path.
-
-#### `--srcroot`
-
-Mockingbird checks the environment variables `SRCROOT` and `SOURCE_ROOT` set by the Xcode build context and then falls back to the directory containing the `.xcodeproj` project file. Note that source root is ignored when using JSON project descriptions.
-
-#### `--outputs`
-
-Mockingbird generates mocks into the directory `$(SRCROOT)/MockingbirdMocks` with the file name `$(PRODUCT_MODULE_NAME)Mocks-$(TEST_TARGET_NAME).generated.swift`.
-
-#### `--support`
-
-Mockingbird recursively looks for [supporting source files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files) in the directory `$(SRCROOT)/MockingbirdSupport`.
-
-#### `--testbundle`
-
-Mockingbird checks the environment variables `TARGET_NAME` and `TARGETNAME` set by the Xcode build context and verifies that it refers to a valid Swift unit test target. The test bundle option must be set when using [JSON project descriptions](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects) in order to enable thunk stubs.
-
-### `--generator`
-
-Mockingbird uses the current executable path and attempts to make it relative to the project’s `SRCROOT` or derived data. To improve portability across development environments, avoid linking executables outside of project-specific directories.
-
-### `--url`
-
-Mockingbird uses the GitHub release artifacts located at `https://github.com/birdrides/mockingbird/releases/download`. Note that asset bundles are versioned by release.
-
-## Additional Resources
-
-### Example Projects
-
-- [CocoaPods](/Examples/CocoaPodsExample)
-- [Carthage](/Examples/CarthageExample)
-- [SwiftPM - Xcode Project](/Examples/SPMProjectExample)
-- [SwiftPM - Package Manifest](/Examples/SPMPackageExample)
-
-### Help and Documentation
-
-- [API reference](https://birdrides.github.io/mockingbird/latest/)
-- [Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
-- [Troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Mockingbird wiki](https://github.com/birdrides/mockingbird/wiki/)
diff --git a/README.md b/README.md
index 8b867f79..4380bfb3 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
-
+
@@ -39,7 +39,7 @@ Mockingbird powers thousands of tests at companies including [Meta](https://meta
### An Example
-Let’s say we wanted to test a `Person` class with a function that takes in a `Bird`.
+Let’s say we wanted to test a `Person` class with a method that takes a `Bird`.
```swift
protocol Bird {
@@ -69,7 +69,7 @@ Person().release(bird)
verify(bird.fly()).wasCalled()
```
-## Installation
+## Quick Start
Select your preferred dependency manager below to get started.
@@ -80,7 +80,7 @@ Add the framework to a test target in your `Podfile`, making sure to include the
```ruby
target 'MyAppTests' do
use_frameworks!
- pod 'MockingbirdFramework', '~> 0.18'
+ pod 'MockingbirdFramework', '~> 0.19'
end
```
@@ -90,10 +90,12 @@ In your project directory, initialize the pod.
$ pod install
```
-Finally, configure a test target to generate mocks for each listed source module. This adds a build phase to the test target which calls [`mockingbird generate`](#generate). For advanced usages, modify the installed build phase or [set up targets manually](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
+Finally, configure the test target to generate mocks for specific modules or libraries.
+
+> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
```console
-$ Pods/MockingbirdFramework/mockingbird install --target MyAppTests --sources MyApp MyLibrary1 MyLibrary2
+$ Pods/MockingbirdFramework/mockingbird configure MyAppTests -- --targets MyApp MyLibrary1 MyLibrary2
```
Optional but recommended:
@@ -105,7 +107,7 @@ Have questions or issues?
- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the CocoaPods example project](/Examples/iOSMockingbirdExample-CocoaPods)
+- [Check out the CocoaPods example project](/Examples/CocoaPodsExample)
@@ -114,7 +116,7 @@ Have questions or issues?
Add the framework to your `Cartfile`.
```
-github "birdrides/mockingbird" ~> 0.18
+github "birdrides/mockingbird" ~> 0.19
```
In your project directory, build the framework and [link it to your test target](https://github.com/birdrides/mockingbird/wiki/Linking-Test-Targets).
@@ -123,10 +125,12 @@ In your project directory, build the framework and [link it to your test target]
$ carthage update --use-xcframeworks
```
-Finally, configure a test target to generate mocks for each listed source module. This adds a build phase to the test target which calls [`mockingbird generate`](#generate). For advanced usages, modify the installed build phase or [set up targets manually](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
+Finally, configure the test target to generate mocks for specific modules or libraries.
+
+> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
```console
-$ mockingbird install --target MyAppTests --sources MyApp MyLibrary1 MyLibrary2
+$ Carthage/Checkouts/mockingbird/mockingbird configure MyAppTests -- --targets MyApp MyLibrary1 MyLibrary2
```
Optional but recommended:
@@ -138,11 +142,47 @@ Have questions or issues?
- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the Carthage example project](/Examples/iOSMockingbirdExample-Carthage)
+- [Check out the Carthage example project](/Examples/CarthageExample)
-Swift Package Manager
+SwiftPM - Xcode Project
+
+Add the framework to your project:
+
+1. Navigate to **File › Add Packages…** and enter `https://github.com/birdrides/mockingbird`
+2. Change **Dependency Rule** to “Up to Next Minor Version” and enter `0.19.0`
+3. Click **Add Package**
+4. Select your test target and click **Add Package**
+
+In your project directory, resolve the derived data path. This can take a few moments.
+
+```console
+$ DERIVED_DATA="$(xcodebuild -showBuildSettings | sed -n 's|.*BUILD_ROOT = \(.*\)/Build/.*|\1|p'
+```
+
+Finally, configure the test target to generate mocks for specific modules or libraries.
+
+> The configurator adds a build phase to the test target which automatically calls [`mockingbird generate`](#generate). You can pass additional arguments to the generator after the double-dash (`--`) or [manually set up targets](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
+
+```console
+$ "${DERIVED_DATA}/SourcePackages/checkouts/mockingbird/mockingbird" configure MyPackageTests -- --targets MyPackage MyLibrary1 MyLibrary2
+```
+
+Optional but recommended:
+
+- [Exclude generated files from source control](https://github.com/birdrides/mockingbird/wiki/Integration-Tips#source-control-exclusion)
+- [Add supporting source files for compatibility with external dependencies](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files)
+
+Have questions or issues?
+
+- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
+- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
+- [Check out the SwiftPM Xcode project example](/Examples/SPMProjectExample)
+
+
+
+SwiftPM - Package Manifest
Add Mockingbird as a package and test target dependency in your `Package.swift` manifest.
@@ -150,7 +190,7 @@ Add Mockingbird as a package and test target dependency in your `Package.swift`
let package = Package(
name: "MyPackage",
dependencies: [
- .package(name: "Mockingbird", url: "https://github.com/birdrides/mockingbird.git", .upToNextMinor(from: "0.18.0")),
+ .package(name: "Mockingbird", url: "https://github.com/birdrides/mockingbird.git", .upToNextMinor(from: "0.19.0")),
],
targets: [
.testTarget(name: "MyPackageTests", dependencies: ["Mockingbird"]),
@@ -158,22 +198,47 @@ let package = Package(
)
```
-In your project directory, initialize the package dependency.
-
-> Parsing the `DERIVED_DATA` path can take a minute.
+In your package directory, initialize the dependency.
```console
-$ xcodebuild -resolvePackageDependencies
-$ DERIVED_DATA="$(xcodebuild -showBuildSettings | pcregrep -o1 'OBJROOT = (/.*)/Build')"
-$ REPO_PATH="${DERIVED_DATA}/SourcePackages/checkouts/mockingbird"
+$ swift package update Mockingbird
```
-Finally, configure a test target to generate mocks for each listed source module. This adds a build phase to the test target which calls [`mockingbird generate`](#generate). For advanced usages, modify the installed build phase or [set up targets manually](https://github.com/birdrides/mockingbird/wiki/Manual-Setup).
+Next, create a Bash script named `gen-mocks.sh` in the same directory as your package manifest. Copy the example below, making sure to change the lines marked with `FIXME`.
-> Not using an Xcode project? Generate mocks from the command line by calling [`mockingbird generate`](#generate).
+```bash
+#!/bin/bash
+set -eu
+cd "$(dirname "$0")"
+swift package describe --type json > project.json
+.build/checkouts/mockingbird/mockingbird generate --project project.json \
+ --output-dir Sources/MyPackageTests/MockingbirdMocks \ # FIXME: Where mocks should be generated.
+ --testbundle MyPackageTests \ # FIXME: Name of your test target.
+ --targets MyPackage MyLibrary1 MyLibrary2 # FIXME: Specific modules or libraries that should be mocked.
+```
+
+Ensure that the script runs and generates mock files.
```console
-$ "${REPO_PATH}/mockingbird" install --target MyPackageTests --sources MyPackage MyLibrary1 MyLibrary2
+$ chmod u+x gen-mocks.sh
+$ ./gen-mocks.sh
+Generated file to MockingbirdMocks/MyPackageTests-MyPackage.generated.swift
+Generated file to MockingbirdMocks/MyPackageTests-MyLibrary1.generated.swift
+Generated file to MockingbirdMocks/MyPackageTests-MyLibrary2.generated.swift
+```
+
+Finally, add each generated mock file to your test target sources.
+
+```swift
+.testTarget(
+ name: "MyPackageTests",
+ dependencies: ["Mockingbird"],
+ sources: [
+ "Tests/MyPackageTests",
+ "MockingbirdMocks/MyPackageTests-MyPackage.generated.swift",
+ "MockingbirdMocks/MyPackageTests-MyLibrary1.generated.swift",
+ "MockingbirdMocks/MyPackageTests-MyLibrary2.generated.swift",
+ ]),
```
Optional but recommended:
@@ -185,7 +250,7 @@ Have questions or issues?
- [Join the Slack channel](https://join.slack.com/t/birdopensource/shared_invite/zt-wogxij50-3ZM7F8ZxFXvPkE0j8xTtmw)
- [Search the troubleshooting guide](https://github.com/birdrides/mockingbird/wiki/Troubleshooting)
-- [Check out the Swift Package Manager example project](/Examples/iOSMockingbirdExample-SPM)
+- [Check out the SwiftPM package manifest example](/Examples/SPMPackageExample)
@@ -662,10 +727,11 @@ Generate mocks for a set of targets in a project.
| Option | Default Value | Description |
| --- | --- | --- |
-| `--targets` | *(required)* | List of target names to generate mocks for. |
-| `--project` | [`(inferred)`](#--project) | Path to an `.xcodeproj` file or a [JSON project description](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects). |
+| `-t, --targets` | *(required)* | List of target names to generate mocks for. |
+| `-o, --outputs` | [`(inferred)`](#--outputs) | List of output file paths corresponding to each target. |
+| `-p, --project` | [`(inferred)`](#--project) | Path to an Xcode project or a [JSON project description](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects). |
+| `--output-dir` | [`(inferred)`](#--outputs) | The directory where generated files should be output. |
| `--srcroot` | [`(inferred)`](#--srcroot) | The directory containing your project’s source files. |
-| `--outputs` | [`(inferred)`](#--outputs) | List of mock output file paths for each target. |
| `--support` | [`(inferred)`](#--support) | The directory containing [supporting source files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files). |
| `--testbundle` | [`(inferred)`](#--testbundle) | The name of the test bundle using the mocks. |
| `--header` | `(none)` | Content to add at the beginning of each generated mock file. |
@@ -676,65 +742,31 @@ Generate mocks for a set of targets in a project.
| Flag | Description |
| --- | --- |
| `--only-protocols` | Only generate mocks for protocols. |
-| `--disable-module-import` | Omit `@testable import ` from generated mocks. |
| `--disable-swiftlint` | Disable all SwiftLint rules in generated mocks. |
| `--disable-cache` | Ignore cached mock information stored on disk. |
| `--disable-relaxed-linking` | Only search explicitly imported modules. |
-### Install
+### Configure
-Configure a test target to use mocks.
+Configure a test target to generate mocks.
-`mockingbird install`
-
-| Option | Default Value | Description |
-| --- | --- | --- |
-| `--target` | *(required)* | The name of a test target to configure. |
-| `--sources` | *(required)* | List of target names to generate mocks for. |
-| `--project` | [`(inferred)`](#--project) | Path to an `.xcodeproj` file or a [JSON project description](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects). |
-| `--srcroot` | [`(inferred)`](#--srcroot) | The directory containing your project’s source files. |
-| `--outputs` | [`(inferred)`](#--outputs) | List of mock output file paths for each target. |
-| `--support` | [`(inferred)`](#--support) | The directory containing [supporting source files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files). |
-| `--header` | `(none)` | Content to add at the beginning of each generated mock file. |
-| `--condition` | `(none)` | [Compilation condition](https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID538) to wrap all generated mocks in, e.g. `DEBUG`. |
-| `--diagnostics` | `(none)` | List of [diagnostic generator warnings](https://github.com/birdrides/mockingbird/wiki/Diagnostic-Warnings-and-Errors) to enable. |
-| `--loglevel` | `(none)` | The log level to use when generating mocks, `quiet` or `verbose`. |
-| `--prune` | `omit` | The [pruning method](#thunk-pruning) to use on unreferenced types. |
+`mockingbird configure -- `
-| Flag | Description |
+| Argument | Description |
| --- | --- |
-| `--preserve-existing` | Don’t overwrite previously installed configurations. |
-| `--asynchronous` | Generate mocks asynchronously in the background when building. |
-| `--only-protocols` | Only generate mocks for protocols. |
-| `--disable-swiftlint` | Disable all SwiftLint rules in generated mocks. |
-| `--disable-cache` | Ignore cached mock information stored on disk. |
-| `--disable-relaxed-linking` | Only search explicitly imported modules. |
-
-### Uninstall
-
-Remove Mockingbird from a test target.
-
-`mockingbird uninstall`
+| `test-target` | The name of a test target to configure. |
+| `generator-options` | Arguments to use when running the generator. See the 'generate' command for all options. |
| Option | Default Value | Description |
| --- | --- | --- |
-| `--targets` | *(required)* | List of target names to uninstall the Run Script Phase. |
-| `--project` | [`(inferred)`](#--project) | Your project’s `.xcodeproj` file. |
-| `--srcroot` | [`(inferred)`](#--srcroot) | The directory containing your project’s source files. |
+| `-p, --project` | [`(inferred)`](#--project) | Path to an Xcode project. |
+| `--srcproject` | [`(inferred)`](#--project) | Path to the Xcode project with source modules, if separate from tests. |
+| `--generator` | [`(inferred)`](#--generator) | Path to the Mockingbird generator executable. |
+| `--url` | [`(inferred)`](#--url) | The base URL hosting downloadable asset bundles. |
-### Download
-
-Download and unpack a compatible asset bundle. Bundles will never overwrite existing files on disk.
-
-`mockingbird download `
-
-| Asset | Description |
+| Flag | Description |
| --- | --- |
-| `starter-pack` | Starter [supporting source files](https://github.com/birdrides/mockingbird/wiki/Supporting-Source-Files). |
-
-| Option | Default Value | Description |
-| --- | --- | --- |
-| `--url` | `https://github.com/birdrides/mockingbird/releases/download` | The base URL containing downloadable asset bundles. |
+| `--preserve-existing` | Keep previously added Mockingbird build phases. |
### Global Options
@@ -742,8 +774,10 @@ Download and unpack a compatible asset bundle. Bundles will never overwrite exis
| --- | --- |
| `--verbose` | Log all errors, warnings, and debug messages. |
| `--quiet` | Only log error messages. |
+| `--version` | Show the version. |
+| `-h, --help` | Show help information. |
-### Inferred Paths
+### Default Inferred Values
#### `--project`
@@ -755,7 +789,7 @@ Mockingbird checks the environment variables `SRCROOT` and `SOURCE_ROOT` set by
#### `--outputs`
-By Mockingbird generates mocks into the directory `$(SRCROOT)/MockingbirdMocks` with the file name `$(PRODUCT_MODULE_NAME)Mocks.generated.swift`.
+Mockingbird generates mocks into the directory `$(SRCROOT)/MockingbirdMocks` with the file name `$(PRODUCT_MODULE_NAME)Mocks-$(TEST_TARGET_NAME).generated.swift`.
#### `--support`
@@ -765,13 +799,22 @@ Mockingbird recursively looks for [supporting source files](https://github.com/b
Mockingbird checks the environment variables `TARGET_NAME` and `TARGETNAME` set by the Xcode build context and verifies that it refers to a valid Swift unit test target. The test bundle option must be set when using [JSON project descriptions](https://github.com/birdrides/mockingbird/wiki/Manual-Setup#generating-mocks-for-non-xcode-projects) in order to enable thunk stubs.
+#### `--generator`
+
+Mockingbird uses the current executable path and attempts to make it relative to the project’s `SRCROOT` or derived data. To improve portability across development environments, avoid linking executables outside of project-specific directories.
+
+#### `--url`
+
+Mockingbird uses the GitHub release artifacts located at `https://github.com/birdrides/mockingbird/releases/download`. Note that asset bundles are versioned by release.
+
## Additional Resources
-### Examples and Tutorials
+### Example Projects
-- [CocoaPods tutorial + example project](/Examples/iOSMockingbirdExample-CocoaPods)
-- [Carthage tutorial + example project](/Examples/iOSMockingbirdExample-Carthage)
-- [Swift Package Manager tutorial + example project](/Examples/iOSMockingbirdExample-SPM)
+- [CocoaPods](/Examples/CocoaPodsExample)
+- [Carthage](/Examples/CarthageExample)
+- [SwiftPM - Xcode Project](/Examples/SPMProjectExample)
+- [SwiftPM - Package Manifest](/Examples/SPMPackageExample)
### Help and Documentation
From fc729dd7f634263ccd17888dea71ef3c7902a37e Mon Sep 17 00:00:00 2001
From: Andrew Chang
Date: Tue, 4 Jan 2022 11:36:11 -1000
Subject: [PATCH 03/20] Remove Swift Doc
---
.gitmodules | 3 -
docs/0.14.0/ArgumentCaptor-1017688/index.html | 181 ---
.../0.14.0/ArgumentMatcher-f013d1a/index.html | 151 --
docs/0.14.0/CountMatcher-4be5ae3/index.html | 262 ---
docs/0.14.0/Declaration-f6338ac/index.html | 129 --
.../FunctionDeclaration-2ccea11/index.html | 119 --
.../ImplementationProvider-c664b1e/index.html | 91 --
.../index.html | 91 --
docs/0.14.0/Mock-28ffcc3/index.html | 146 --
docs/0.14.0/MockMetadata-36657c4/index.html | 59 -
docs/0.14.0/Mockable-9a5a67c/index.html | 59 -
docs/0.14.0/MockingContext-c5faed5/index.html | 59 -
.../NonEscapingClosure-e61507c/index.html | 85 -
.../index.html | 210 ---
.../index.html | 103 --
.../index.html | 103 --
docs/0.14.0/Providable-7bc5aa7/index.html | 105 --
docs/0.14.0/SourceLocation-656fd60/index.html | 59 -
docs/0.14.0/StaticMock-882efeb/index.html | 146 --
.../0.14.0/StubbingContext-794fb76/index.html | 59 -
.../0.14.0/StubbingManager-761d798/index.html | 238 ---
.../index.html | 118 --
.../SubscriptDeclaration-38e94f4/index.html | 132 --
.../index.html | 103 --
.../index.html | 103 --
docs/0.14.0/TestFailer-4ae7a4d/index.html | 109 --
.../index.html | 103 --
docs/0.14.0/ValueProvider-7c6afc8/index.html | 583 -------
.../VariableDeclaration-c075015/index.html | 132 --
.../VerificationManager-94d5cc8/index.html | 174 --
docs/0.14.0/all.css | 1 -
docs/0.14.0/any(_:)-da61986/index.html | 103 --
.../any(_:containing:)-0e18f78/index.html | 110 --
.../any(_:containing:)-365e26e/index.html | 127 --
docs/0.14.0/any(_:count:)-860fd11/index.html | 107 --
docs/0.14.0/any(_:keys:)-e7f89d4/index.html | 126 --
docs/0.14.0/any(_:of:)-89cb3ec/index.html | 125 --
docs/0.14.0/any(_:of:)-e376f19/index.html | 111 --
docs/0.14.0/any(_:where:)-ea2d92e/index.html | 118 --
.../around(_:tolerance:)-831b19f/index.html | 94 --
docs/0.14.0/atLeast(_:)-c832002/index.html | 93 --
docs/0.14.0/atMost(_:)-a2b82d3/index.html | 93 --
docs/0.14.0/between(_:)-cfca747/index.html | 92 --
.../index.html | 88 -
.../clearInvocations(on:)-4120e8f/index.html | 88 -
.../0.14.0/clearStubs(on:)-f985ed7/index.html | 88 -
.../eventually(_:_:)-28d4191/index.html | 99 --
docs/0.14.0/exactly(_:)-47abdfc/index.html | 92 --
.../finiteSequence(of:)-9390bb3/index.html | 85 -
.../finiteSequence(of:)-ff3ed8b/index.html | 89 --
docs/0.14.0/given(_:)-05dd78f/index.html | 96 --
.../index.html | 117 --
docs/0.14.0/index.html | 677 --------
.../lastSetValue(initial:)-576c55c/index.html | 73 -
.../loopingSequence(of:)-8ab9cb4/index.html | 87 -
.../loopingSequence(of:)-9da831b/index.html | 90 --
docs/0.14.0/never-9661ceb/index.html | 54 -
docs/0.14.0/not(_:)-3f926b2/index.html | 84 -
docs/0.14.0/not(_:)-cf99a2a/index.html | 84 -
docs/0.14.0/notEmpty(_:)-3cab350/index.html | 101 --
docs/0.14.0/notNil(_:)-42278eb/index.html | 101 --
docs/0.14.0/once-3db83dd/index.html | 54 -
docs/0.14.0/reset(_:)-2a0feaf/index.html | 89 --
docs/0.14.0/sequence(of:)-c40bb93/index.html | 89 --
docs/0.14.0/sequence(of:)-d9da3e4/index.html | 85 -
.../swizzleTestFailer(_:)-d923326/index.html | 73 -
docs/0.14.0/twice-f36cfd6/index.html | 54 -
.../index.html | 115 --
.../index.html | 122 --
.../verify(_:file:line:)-a722fba/index.html | 87 -
docs/0.15.0/ArgumentCaptor-1017688/index.html | 181 ---
.../0.15.0/ArgumentMatcher-f013d1a/index.html | 151 --
docs/0.15.0/CountMatcher-4be5ae3/index.html | 262 ---
docs/0.15.0/Declaration-f6338ac/index.html | 129 --
.../FunctionDeclaration-2ccea11/index.html | 119 --
.../ImplementationProvider-c664b1e/index.html | 91 --
.../index.html | 91 --
docs/0.15.0/Mock-28ffcc3/index.html | 146 --
docs/0.15.0/MockMetadata-36657c4/index.html | 59 -
docs/0.15.0/Mockable-9a5a67c/index.html | 59 -
docs/0.15.0/MockingContext-c5faed5/index.html | 59 -
.../NonEscapingClosure-e61507c/index.html | 85 -
.../index.html | 210 ---
.../index.html | 103 --
.../index.html | 103 --
docs/0.15.0/Providable-7bc5aa7/index.html | 105 --
docs/0.15.0/SourceLocation-656fd60/index.html | 59 -
docs/0.15.0/StaticMock-882efeb/index.html | 146 --
.../0.15.0/StubbingContext-794fb76/index.html | 59 -
.../0.15.0/StubbingManager-761d798/index.html | 238 ---
.../index.html | 118 --
.../SubscriptDeclaration-38e94f4/index.html | 132 --
.../index.html | 72 -
.../index.html | 103 --
docs/0.15.0/SwiftSymbol-df7f148/index.html | 181 ---
.../SwiftSymbolParseError-99165a5/index.html | 170 --
.../SwiftSymbol_Contents-7f818fc/index.html | 84 -
.../SwiftSymbol_Kind-a459168/index.html | 1356 ----------------
.../SymbolPrintOptions-8c5ff04/index.html | 228 ---
docs/0.15.0/TestFailer-4ae7a4d/index.html | 109 --
.../index.html | 103 --
docs/0.15.0/ValueProvider-54037ad/index.html | 550 -------
.../VariableDeclaration-c075015/index.html | 132 --
.../VerificationManager-94d5cc8/index.html | 174 --
docs/0.15.0/all.css | 1 -
docs/0.15.0/any(_:)-da61986/index.html | 103 --
.../any(_:containing:)-0e18f78/index.html | 110 --
.../any(_:containing:)-365e26e/index.html | 127 --
docs/0.15.0/any(_:count:)-860fd11/index.html | 107 --
docs/0.15.0/any(_:keys:)-e7f89d4/index.html | 126 --
docs/0.15.0/any(_:of:)-89cb3ec/index.html | 125 --
docs/0.15.0/any(_:of:)-e376f19/index.html | 111 --
docs/0.15.0/any(_:where:)-ea2d92e/index.html | 118 --
.../around(_:tolerance:)-831b19f/index.html | 94 --
docs/0.15.0/atLeast(_:)-c832002/index.html | 93 --
docs/0.15.0/atMost(_:)-a2b82d3/index.html | 93 --
docs/0.15.0/between(_:)-cfca747/index.html | 92 --
.../index.html | 88 -
.../clearInvocations(on:)-4120e8f/index.html | 88 -
.../0.15.0/clearStubs(on:)-f985ed7/index.html | 88 -
.../eventually(_:_:)-28d4191/index.html | 99 --
docs/0.15.0/exactly(_:)-47abdfc/index.html | 92 --
.../finiteSequence(of:)-9390bb3/index.html | 85 -
.../finiteSequence(of:)-ff3ed8b/index.html | 89 --
docs/0.15.0/given(_:)-05dd78f/index.html | 96 --
.../index.html | 117 --
docs/0.15.0/index.html | 746 ---------
.../lastSetValue(initial:)-576c55c/index.html | 73 -
.../loopingSequence(of:)-8ab9cb4/index.html | 87 -
.../loopingSequence(of:)-9da831b/index.html | 90 --
docs/0.15.0/mock(_:)-b93ee0e/index.html | 94 --
docs/0.15.0/never-9661ceb/index.html | 54 -
docs/0.15.0/not(_:)-3f926b2/index.html | 84 -
docs/0.15.0/not(_:)-cf99a2a/index.html | 84 -
docs/0.15.0/notEmpty(_:)-3cab350/index.html | 101 --
docs/0.15.0/notNil(_:)-42278eb/index.html | 101 --
docs/0.15.0/once-3db83dd/index.html | 54 -
.../index.html | 85 -
.../index.html | 85 -
docs/0.15.0/reset(_:)-2a0feaf/index.html | 89 --
docs/0.15.0/sequence(of:)-c40bb93/index.html | 89 --
docs/0.15.0/sequence(of:)-d9da3e4/index.html | 85 -
.../swizzleTestFailer(_:)-d923326/index.html | 73 -
docs/0.15.0/twice-f36cfd6/index.html | 54 -
.../index.html | 115 --
.../index.html | 122 --
.../verify(_:file:line:)-a722fba/index.html | 87 -
docs/0.16.0/ArgumentCaptor-1017688/index.html | 181 ---
.../0.16.0/ArgumentMatcher-f013d1a/index.html | 151 --
docs/0.16.0/CountMatcher-4be5ae3/index.html | 262 ---
docs/0.16.0/Declaration-f6338ac/index.html | 129 --
.../FunctionDeclaration-2ccea11/index.html | 119 --
.../ImplementationProvider-c664b1e/index.html | 91 --
.../index.html | 91 --
docs/0.16.0/Mock-28ffcc3/index.html | 146 --
docs/0.16.0/MockMetadata-36657c4/index.html | 59 -
docs/0.16.0/Mockable-9a5a67c/index.html | 59 -
docs/0.16.0/MockingContext-c5faed5/index.html | 59 -
.../NonEscapingClosure-e61507c/index.html | 85 -
.../index.html | 210 ---
.../index.html | 103 --
.../index.html | 103 --
docs/0.16.0/Providable-7bc5aa7/index.html | 105 --
docs/0.16.0/SourceLocation-656fd60/index.html | 59 -
docs/0.16.0/StaticMock-882efeb/index.html | 146 --
.../0.16.0/StubbingContext-794fb76/index.html | 59 -
.../0.16.0/StubbingManager-761d798/index.html | 238 ---
.../index.html | 118 --
.../SubscriptDeclaration-38e94f4/index.html | 132 --
.../index.html | 103 --
.../index.html | 103 --
docs/0.16.0/TestFailer-4ae7a4d/index.html | 109 --
.../index.html | 103 --
docs/0.16.0/ValueProvider-54037ad/index.html | 550 -------
.../VariableDeclaration-c075015/index.html | 132 --
.../VerificationManager-94d5cc8/index.html | 174 --
docs/0.16.0/all.css | 1 -
docs/0.16.0/any(_:)-da61986/index.html | 103 --
.../any(_:containing:)-0e18f78/index.html | 110 --
.../any(_:containing:)-365e26e/index.html | 127 --
docs/0.16.0/any(_:count:)-860fd11/index.html | 107 --
docs/0.16.0/any(_:keys:)-e7f89d4/index.html | 126 --
docs/0.16.0/any(_:of:)-89cb3ec/index.html | 125 --
docs/0.16.0/any(_:of:)-e376f19/index.html | 111 --
docs/0.16.0/any(_:where:)-ea2d92e/index.html | 118 --
.../around(_:tolerance:)-831b19f/index.html | 94 --
docs/0.16.0/atLeast(_:)-c832002/index.html | 93 --
docs/0.16.0/atMost(_:)-a2b82d3/index.html | 93 --
docs/0.16.0/between(_:)-cfca747/index.html | 92 --
.../index.html | 88 -
.../clearInvocations(on:)-4120e8f/index.html | 88 -
.../0.16.0/clearStubs(on:)-f985ed7/index.html | 88 -
.../eventually(_:_:)-28d4191/index.html | 99 --
docs/0.16.0/exactly(_:)-47abdfc/index.html | 92 --
.../finiteSequence(of:)-9390bb3/index.html | 85 -
.../finiteSequence(of:)-ff3ed8b/index.html | 89 --
docs/0.16.0/given(_:)-05dd78f/index.html | 96 --
.../index.html | 117 --
docs/0.16.0/index.html | 686 --------
.../lastSetValue(initial:)-576c55c/index.html | 73 -
.../loopingSequence(of:)-8ab9cb4/index.html | 87 -
.../loopingSequence(of:)-9da831b/index.html | 90 --
docs/0.16.0/mock(_:)-b93ee0e/index.html | 94 --
docs/0.16.0/never-9661ceb/index.html | 54 -
docs/0.16.0/not(_:)-3f926b2/index.html | 84 -
docs/0.16.0/not(_:)-cf99a2a/index.html | 84 -
docs/0.16.0/notEmpty(_:)-3cab350/index.html | 101 --
docs/0.16.0/notNil(_:)-42278eb/index.html | 101 --
docs/0.16.0/once-3db83dd/index.html | 54 -
docs/0.16.0/reset(_:)-2a0feaf/index.html | 89 --
docs/0.16.0/sequence(of:)-c40bb93/index.html | 89 --
docs/0.16.0/sequence(of:)-d9da3e4/index.html | 85 -
.../swizzleTestFailer(_:)-d923326/index.html | 73 -
docs/0.16.0/twice-f36cfd6/index.html | 54 -
.../index.html | 115 --
.../index.html | 122 --
.../verify(_:file:line:)-a722fba/index.html | 87 -
docs/0.17.0/ArgumentCaptor-94fb876/index.html | 196 ---
.../0.17.0/ArgumentMatcher-1c43b93/index.html | 166 --
docs/0.17.0/Array/index.html | 60 -
docs/0.17.0/CountMatcher-6825dbf/index.html | 274 ----
docs/0.17.0/Declaration-61b39f6/index.html | 146 --
docs/0.17.0/Dictionary/index.html | 60 -
.../FunctionDeclaration-9288d96/index.html | 131 --
.../ImplementationProvider-ebb9664/index.html | 95 --
.../index.html | 94 --
docs/0.17.0/Mock-1448bd4/index.html | 232 ---
docs/0.17.0/MockMetadata-491926a/index.html | 61 -
docs/0.17.0/Mockable-92ced01/index.html | 61 -
docs/0.17.0/MockingContext-e8084fb/index.html | 61 -
.../NonEscapingClosure-ac8dd96/index.html | 87 -
docs/0.17.0/Optional/index.html | 60 -
.../index.html | 224 ---
.../index.html | 110 --
.../index.html | 110 --
docs/0.17.0/Providable-fd593f8/index.html | 109 --
docs/0.17.0/Set/index.html | 60 -
docs/0.17.0/SourceLocation-e12b876/index.html | 61 -
docs/0.17.0/StaticMock-a04a7c2/index.html | 161 --
.../0.17.0/StubbingContext-c368434/index.html | 61 -
.../0.17.0/StubbingManager-c41b02a/index.html | 252 ---
.../index.html | 124 --
.../SubscriptDeclaration-c38cdc6/index.html | 149 --
.../index.html | 110 --
.../index.html | 110 --
docs/0.17.0/TestFailer-f9088cc/index.html | 113 --
.../index.html | 110 --
docs/0.17.0/ValueProvider-242b058/index.html | 593 -------
.../VariableDeclaration-f83ff6c/index.html | 149 --
.../VerificationManager-0d29384/index.html | 184 ---
docs/0.17.0/all.css | 1 -
docs/0.17.0/any(_:)-57c9fd0/index.html | 105 --
.../any(_:containing:)-095611c/index.html | 130 --
.../any(_:containing:)-44dd020/index.html | 112 --
docs/0.17.0/any(_:count:)-dbbc1fd/index.html | 109 --
docs/0.17.0/any(_:keys:)-8ca4847/index.html | 129 --
docs/0.17.0/any(_:of:)-0eb9154/index.html | 127 --
docs/0.17.0/any(_:of:)-64e400e/index.html | 113 --
docs/0.17.0/any(_:where:)-aeec51b/index.html | 120 --
.../around(_:tolerance:)-00be404/index.html | 96 --
docs/0.17.0/atLeast(_:)-898a2b0/index.html | 95 --
docs/0.17.0/atMost(_:)-3e1c32b/index.html | 95 --
docs/0.17.0/between(_:)-d57ee49/index.html | 94 --
.../index.html | 90 --
.../clearInvocations(on:)-c035ab0/index.html | 90 --
.../0.17.0/clearStubs(on:)-733a109/index.html | 90 --
.../eventually(_:_:)-4bc028a/index.html | 102 --
docs/0.17.0/exactly(_:)-c366d42/index.html | 94 --
.../finiteSequence(of:)-4225436/index.html | 93 --
.../finiteSequence(of:)-b90973c/index.html | 89 --
docs/0.17.0/given(_:)-8e1ce81/index.html | 100 --
.../index.html | 121 --
docs/0.17.0/index.html | 721 ---------
.../lastSetValue(initial:)-d6a1a47/index.html | 77 -
.../loopingSequence(of:)-8c11ab6/index.html | 91 --
.../loopingSequence(of:)-cc3f2b3/index.html | 94 --
docs/0.17.0/mock(_:)-40a8117/index.html | 97 --
docs/0.17.0/never-657a74c/index.html | 56 -
docs/0.17.0/not(_:)-12c53a2/index.html | 86 -
docs/0.17.0/not(_:)-90155c4/index.html | 86 -
docs/0.17.0/notEmpty(_:)-42ce3f8/index.html | 103 --
docs/0.17.0/notNil(_:)-4da033f/index.html | 103 --
docs/0.17.0/once-dc7031f/index.html | 56 -
docs/0.17.0/reset(_:)-5654439/index.html | 91 --
docs/0.17.0/sequence(of:)-8b3c523/index.html | 89 --
docs/0.17.0/sequence(of:)-af09516/index.html | 93 --
.../swizzleTestFailer(_:)-8147916/index.html | 75 -
docs/0.17.0/twice-b13bfea/index.html | 56 -
.../index.html | 117 --
.../index.html | 124 --
.../verify(_:file:line:)-a5a6b2f/index.html | 92 --
docs/0.18.0/AnyDeclaration-762b5df/index.html | 110 --
docs/0.18.0/ArgumentCaptor-94fb876/index.html | 225 ---
.../0.18.0/ArgumentMatcher-e2bb17a/index.html | 171 --
docs/0.18.0/Array/index.html | 60 -
docs/0.18.0/Context-67f9dcd/index.html | 156 --
docs/0.18.0/CountMatcher-6825dbf/index.html | 274 ----
docs/0.18.0/Declaration-61b39f6/index.html | 164 --
docs/0.18.0/Dictionary/index.html | 60 -
.../DynamicStubbingManager-824a4fd/index.html | 1226 --------------
docs/0.18.0/ErrorBox-1b2dcf7/index.html | 144 --
.../ForwardingContext-feff474/index.html | 61 -
.../FunctionDeclaration-9288d96/index.html | 131 --
.../ImplementationProvider-ebb9664/index.html | 95 --
.../InvocationRecorder-7d70b12/index.html | 154 --
.../index.html | 138 --
docs/0.18.0/Mock-ad39d03/index.html | 337 ----
docs/0.18.0/MockMetadata-491926a/index.html | 61 -
docs/0.18.0/Mockable-92ced01/index.html | 61 -
docs/0.18.0/MockingContext-c31b095/index.html | 121 --
docs/0.18.0/NSObjectProtocol/index.html | 245 ---
.../NonEscapingClosure-ac8dd96/index.html | 87 -
docs/0.18.0/ObjCErrorBox-ece9985/index.html | 121 --
docs/0.18.0/ObjCInvocation-9ef7ffe/index.html | 144 --
docs/0.18.0/Optional/index.html | 60 -
.../index.html | 224 ---
.../index.html | 110 --
.../index.html | 110 --
docs/0.18.0/Providable-fd593f8/index.html | 109 --
docs/0.18.0/ProxyContext-67feefc/index.html | 120 --
docs/0.18.0/SelectorType-d2b8230/index.html | 173 --
docs/0.18.0/Set/index.html | 60 -
docs/0.18.0/SourceLocation-e12b876/index.html | 61 -
docs/0.18.0/StaticMock-a04a7c2/index.html | 125 --
.../StaticStubbingManager-5a4489d/index.html | 106 --
.../0.18.0/StubbingContext-d729e61/index.html | 204 ---
.../0.18.0/StubbingManager-c41b02a/index.html | 393 -----
.../index.html | 124 --
.../SubscriptDeclaration-c38cdc6/index.html | 149 --
.../index.html | 110 --
.../index.html | 110 --
docs/0.18.0/SwiftErrorBox-a9850af/index.html | 121 --
docs/0.18.0/TestFailer-f9088cc/index.html | 113 --
.../index.html | 110 --
docs/0.18.0/ValueProvider-242b058/index.html | 559 -------
.../VariableDeclaration-f83ff6c/index.html | 149 --
.../VerificationManager-4f75443/index.html | 184 ---
docs/0.18.0/all.css | 1 -
docs/0.18.0/any(_:)-04561d1/index.html | 106 --
docs/0.18.0/any(_:)-57c9fd0/index.html | 100 --
.../any(_:containing:)-095611c/index.html | 130 --
.../any(_:containing:)-44dd020/index.html | 112 --
docs/0.18.0/any(_:count:)-dbbc1fd/index.html | 109 --
docs/0.18.0/any(_:keys:)-8ca4847/index.html | 129 --
docs/0.18.0/any(_:of:)-0eb9154/index.html | 127 --
docs/0.18.0/any(_:of:)-64e400e/index.html | 113 --
docs/0.18.0/any(_:where:)-aeec51b/index.html | 120 --
docs/0.18.0/any(_:where:)-faad7a5/index.html | 122 --
docs/0.18.0/arg(_:at:)-e5b4d4c/index.html | 108 --
.../around(_:tolerance:)-00be404/index.html | 96 --
docs/0.18.0/atLeast(_:)-898a2b0/index.html | 95 --
docs/0.18.0/atMost(_:)-3e1c32b/index.html | 95 --
docs/0.18.0/between(_:)-d57ee49/index.html | 94 --
.../index.html | 90 --
.../clearInvocations(on:)-3b83feb/index.html | 90 --
.../clearInvocations(on:)-c035ab0/index.html | 90 --
.../0.18.0/clearStubs(on:)-343b2f1/index.html | 89 --
.../0.18.0/clearStubs(on:)-733a109/index.html | 89 --
.../eventually(_:_:)-4bc028a/index.html | 102 --
docs/0.18.0/exactly(_:)-c366d42/index.html | 94 --
docs/0.18.0/fifthArg(_:)-b65d250/index.html | 102 --
.../finiteSequence(of:)-4225436/index.html | 93 --
.../finiteSequence(of:)-b90973c/index.html | 89 --
docs/0.18.0/firstArg(_:)-ca2e527/index.html | 102 --
docs/0.18.0/forward(to:)-28668e8/index.html | 115 --
.../forwardToSuper()-5c5eb13/index.html | 89 --
docs/0.18.0/fourthArg(_:)-17b6638/index.html | 102 --
docs/0.18.0/given(_:)-8aeefd4/index.html | 120 --
docs/0.18.0/given(_:)-a96595c/index.html | 105 --
.../index.html | 121 --
docs/0.18.0/index.html | 968 -----------
.../lastSetValue(initial:)-d6a1a47/index.html | 87 -
.../loopingSequence(of:)-8c11ab6/index.html | 91 --
.../loopingSequence(of:)-cc3f2b3/index.html | 94 --
docs/0.18.0/mock(_:)-40a8117/index.html | 97 --
docs/0.18.0/mock(_:)-b58cf6a/index.html | 104 --
docs/0.18.0/never-657a74c/index.html | 56 -
docs/0.18.0/not(_:)-12c53a2/index.html | 86 -
docs/0.18.0/not(_:)-90155c4/index.html | 86 -
docs/0.18.0/notEmpty(_:)-42ce3f8/index.html | 103 --
docs/0.18.0/notNil(_:)-4c25f3f/index.html | 105 --
docs/0.18.0/notNil(_:)-4da033f/index.html | 103 --
docs/0.18.0/once-dc7031f/index.html | 56 -
docs/0.18.0/reset(_:)-5654439/index.html | 91 --
docs/0.18.0/reset(_:)-76ccf89/index.html | 91 --
docs/0.18.0/secondArg(_:)-39c95e2/index.html | 102 --
docs/0.18.0/sequence(of:)-8b3c523/index.html | 89 --
docs/0.18.0/sequence(of:)-af09516/index.html | 93 --
.../swizzleTestFailer(_:)-8147916/index.html | 75 -
docs/0.18.0/thirdArg(_:)-4eaa586/index.html | 102 --
docs/0.18.0/twice-b13bfea/index.html | 56 -
.../verify(_:file:line:)-023a535/index.html | 92 --
.../verify(_:file:line:)-a5a6b2f/index.html | 92 --
docs/0.18.0/~>-561b2ad/index.html | 1420 -----------------
docs/Mockingbird.docc/Info.plist | 14 +
docs/images/mockingbird-hero-image.png | Bin 57444 -> 0 bytes
docs/index.html | 1 -
docs/latest/index.html | 1 -
docs/swift-doc | 1 -
399 files changed, 14 insertions(+), 51867 deletions(-)
delete mode 100644 .gitmodules
delete mode 100755 docs/0.14.0/ArgumentCaptor-1017688/index.html
delete mode 100755 docs/0.14.0/ArgumentMatcher-f013d1a/index.html
delete mode 100755 docs/0.14.0/CountMatcher-4be5ae3/index.html
delete mode 100755 docs/0.14.0/Declaration-f6338ac/index.html
delete mode 100755 docs/0.14.0/FunctionDeclaration-2ccea11/index.html
delete mode 100755 docs/0.14.0/ImplementationProvider-c664b1e/index.html
delete mode 100755 docs/0.14.0/MKBFail(_:isFatal:file:line:)-c41bd8d/index.html
delete mode 100755 docs/0.14.0/Mock-28ffcc3/index.html
delete mode 100755 docs/0.14.0/MockMetadata-36657c4/index.html
delete mode 100755 docs/0.14.0/Mockable-9a5a67c/index.html
delete mode 100755 docs/0.14.0/MockingContext-c5faed5/index.html
delete mode 100755 docs/0.14.0/NonEscapingClosure-e61507c/index.html
delete mode 100755 docs/0.14.0/OrderedVerificationOptions-77823cc/index.html
delete mode 100755 docs/0.14.0/PropertyGetterDeclaration-db9ea0d/index.html
delete mode 100755 docs/0.14.0/PropertySetterDeclaration-7cfb3cc/index.html
delete mode 100755 docs/0.14.0/Providable-7bc5aa7/index.html
delete mode 100755 docs/0.14.0/SourceLocation-656fd60/index.html
delete mode 100755 docs/0.14.0/StaticMock-882efeb/index.html
delete mode 100755 docs/0.14.0/StubbingContext-794fb76/index.html
delete mode 100755 docs/0.14.0/StubbingManager-761d798/index.html
delete mode 100755 docs/0.14.0/StubbingManager_TransitionStrategy-9f44b8f/index.html
delete mode 100755 docs/0.14.0/SubscriptDeclaration-38e94f4/index.html
delete mode 100755 docs/0.14.0/SubscriptGetterDeclaration-2324199/index.html
delete mode 100755 docs/0.14.0/SubscriptSetterDeclaration-a66f358/index.html
delete mode 100755 docs/0.14.0/TestFailer-4ae7a4d/index.html
delete mode 100755 docs/0.14.0/ThrowingFunctionDeclaration-9b512dc/index.html
delete mode 100755 docs/0.14.0/ValueProvider-7c6afc8/index.html
delete mode 100755 docs/0.14.0/VariableDeclaration-c075015/index.html
delete mode 100755 docs/0.14.0/VerificationManager-94d5cc8/index.html
delete mode 100755 docs/0.14.0/all.css
delete mode 100755 docs/0.14.0/any(_:)-da61986/index.html
delete mode 100755 docs/0.14.0/any(_:containing:)-0e18f78/index.html
delete mode 100755 docs/0.14.0/any(_:containing:)-365e26e/index.html
delete mode 100755 docs/0.14.0/any(_:count:)-860fd11/index.html
delete mode 100755 docs/0.14.0/any(_:keys:)-e7f89d4/index.html
delete mode 100755 docs/0.14.0/any(_:of:)-89cb3ec/index.html
delete mode 100755 docs/0.14.0/any(_:of:)-e376f19/index.html
delete mode 100755 docs/0.14.0/any(_:where:)-ea2d92e/index.html
delete mode 100755 docs/0.14.0/around(_:tolerance:)-831b19f/index.html
delete mode 100755 docs/0.14.0/atLeast(_:)-c832002/index.html
delete mode 100755 docs/0.14.0/atMost(_:)-a2b82d3/index.html
delete mode 100755 docs/0.14.0/between(_:)-cfca747/index.html
delete mode 100755 docs/0.14.0/clearDefaultValues(on:)-112773d/index.html
delete mode 100755 docs/0.14.0/clearInvocations(on:)-4120e8f/index.html
delete mode 100755 docs/0.14.0/clearStubs(on:)-f985ed7/index.html
delete mode 100755 docs/0.14.0/eventually(_:_:)-28d4191/index.html
delete mode 100755 docs/0.14.0/exactly(_:)-47abdfc/index.html
delete mode 100755 docs/0.14.0/finiteSequence(of:)-9390bb3/index.html
delete mode 100755 docs/0.14.0/finiteSequence(of:)-ff3ed8b/index.html
delete mode 100755 docs/0.14.0/given(_:)-05dd78f/index.html
delete mode 100755 docs/0.14.0/inOrder(with:file:line:_:)-3c038cb/index.html
delete mode 100755 docs/0.14.0/index.html
delete mode 100755 docs/0.14.0/lastSetValue(initial:)-576c55c/index.html
delete mode 100755 docs/0.14.0/loopingSequence(of:)-8ab9cb4/index.html
delete mode 100755 docs/0.14.0/loopingSequence(of:)-9da831b/index.html
delete mode 100755 docs/0.14.0/never-9661ceb/index.html
delete mode 100755 docs/0.14.0/not(_:)-3f926b2/index.html
delete mode 100755 docs/0.14.0/not(_:)-cf99a2a/index.html
delete mode 100755 docs/0.14.0/notEmpty(_:)-3cab350/index.html
delete mode 100755 docs/0.14.0/notNil(_:)-42278eb/index.html
delete mode 100755 docs/0.14.0/once-3db83dd/index.html
delete mode 100755 docs/0.14.0/reset(_:)-2a0feaf/index.html
delete mode 100755 docs/0.14.0/sequence(of:)-c40bb93/index.html
delete mode 100755 docs/0.14.0/sequence(of:)-d9da3e4/index.html
delete mode 100755 docs/0.14.0/swizzleTestFailer(_:)-d923326/index.html
delete mode 100755 docs/0.14.0/twice-f36cfd6/index.html
delete mode 100755 docs/0.14.0/useDefaultValues(from:on:)-5df93fa/index.html
delete mode 100755 docs/0.14.0/useDefaultValues(from:on:)-7eb6cc5/index.html
delete mode 100755 docs/0.14.0/verify(_:file:line:)-a722fba/index.html
delete mode 100755 docs/0.15.0/ArgumentCaptor-1017688/index.html
delete mode 100755 docs/0.15.0/ArgumentMatcher-f013d1a/index.html
delete mode 100755 docs/0.15.0/CountMatcher-4be5ae3/index.html
delete mode 100755 docs/0.15.0/Declaration-f6338ac/index.html
delete mode 100755 docs/0.15.0/FunctionDeclaration-2ccea11/index.html
delete mode 100755 docs/0.15.0/ImplementationProvider-c664b1e/index.html
delete mode 100755 docs/0.15.0/MKBFail(_:isFatal:file:line:)-c41bd8d/index.html
delete mode 100755 docs/0.15.0/Mock-28ffcc3/index.html
delete mode 100755 docs/0.15.0/MockMetadata-36657c4/index.html
delete mode 100755 docs/0.15.0/Mockable-9a5a67c/index.html
delete mode 100755 docs/0.15.0/MockingContext-c5faed5/index.html
delete mode 100755 docs/0.15.0/NonEscapingClosure-e61507c/index.html
delete mode 100755 docs/0.15.0/OrderedVerificationOptions-77823cc/index.html
delete mode 100755 docs/0.15.0/PropertyGetterDeclaration-db9ea0d/index.html
delete mode 100755 docs/0.15.0/PropertySetterDeclaration-7cfb3cc/index.html
delete mode 100755 docs/0.15.0/Providable-7bc5aa7/index.html
delete mode 100755 docs/0.15.0/SourceLocation-656fd60/index.html
delete mode 100755 docs/0.15.0/StaticMock-882efeb/index.html
delete mode 100755 docs/0.15.0/StubbingContext-794fb76/index.html
delete mode 100755 docs/0.15.0/StubbingManager-761d798/index.html
delete mode 100755 docs/0.15.0/StubbingManager_TransitionStrategy-9f44b8f/index.html
delete mode 100755 docs/0.15.0/SubscriptDeclaration-38e94f4/index.html
delete mode 100755 docs/0.15.0/SubscriptGetterDeclaration-2324199/index.html
delete mode 100755 docs/0.15.0/SubscriptSetterDeclaration-a66f358/index.html
delete mode 100755 docs/0.15.0/SwiftSymbol-df7f148/index.html
delete mode 100755 docs/0.15.0/SwiftSymbolParseError-99165a5/index.html
delete mode 100755 docs/0.15.0/SwiftSymbol_Contents-7f818fc/index.html
delete mode 100755 docs/0.15.0/SwiftSymbol_Kind-a459168/index.html
delete mode 100755 docs/0.15.0/SymbolPrintOptions-8c5ff04/index.html
delete mode 100755 docs/0.15.0/TestFailer-4ae7a4d/index.html
delete mode 100755 docs/0.15.0/ThrowingFunctionDeclaration-9b512dc/index.html
delete mode 100755 docs/0.15.0/ValueProvider-54037ad/index.html
delete mode 100755 docs/0.15.0/VariableDeclaration-c075015/index.html
delete mode 100755 docs/0.15.0/VerificationManager-94d5cc8/index.html
delete mode 100755 docs/0.15.0/all.css
delete mode 100755 docs/0.15.0/any(_:)-da61986/index.html
delete mode 100755 docs/0.15.0/any(_:containing:)-0e18f78/index.html
delete mode 100755 docs/0.15.0/any(_:containing:)-365e26e/index.html
delete mode 100755 docs/0.15.0/any(_:count:)-860fd11/index.html
delete mode 100755 docs/0.15.0/any(_:keys:)-e7f89d4/index.html
delete mode 100755 docs/0.15.0/any(_:of:)-89cb3ec/index.html
delete mode 100755 docs/0.15.0/any(_:of:)-e376f19/index.html
delete mode 100755 docs/0.15.0/any(_:where:)-ea2d92e/index.html
delete mode 100755 docs/0.15.0/around(_:tolerance:)-831b19f/index.html
delete mode 100755 docs/0.15.0/atLeast(_:)-c832002/index.html
delete mode 100755 docs/0.15.0/atMost(_:)-a2b82d3/index.html
delete mode 100755 docs/0.15.0/between(_:)-cfca747/index.html
delete mode 100755 docs/0.15.0/clearDefaultValues(on:)-112773d/index.html
delete mode 100755 docs/0.15.0/clearInvocations(on:)-4120e8f/index.html
delete mode 100755 docs/0.15.0/clearStubs(on:)-f985ed7/index.html
delete mode 100755 docs/0.15.0/eventually(_:_:)-28d4191/index.html
delete mode 100755 docs/0.15.0/exactly(_:)-47abdfc/index.html
delete mode 100755 docs/0.15.0/finiteSequence(of:)-9390bb3/index.html
delete mode 100755 docs/0.15.0/finiteSequence(of:)-ff3ed8b/index.html
delete mode 100755 docs/0.15.0/given(_:)-05dd78f/index.html
delete mode 100755 docs/0.15.0/inOrder(with:file:line:_:)-3c038cb/index.html
delete mode 100755 docs/0.15.0/index.html
delete mode 100755 docs/0.15.0/lastSetValue(initial:)-576c55c/index.html
delete mode 100755 docs/0.15.0/loopingSequence(of:)-8ab9cb4/index.html
delete mode 100755 docs/0.15.0/loopingSequence(of:)-9da831b/index.html
delete mode 100755 docs/0.15.0/mock(_:)-b93ee0e/index.html
delete mode 100755 docs/0.15.0/never-9661ceb/index.html
delete mode 100755 docs/0.15.0/not(_:)-3f926b2/index.html
delete mode 100755 docs/0.15.0/not(_:)-cf99a2a/index.html
delete mode 100755 docs/0.15.0/notEmpty(_:)-3cab350/index.html
delete mode 100755 docs/0.15.0/notNil(_:)-42278eb/index.html
delete mode 100755 docs/0.15.0/once-3db83dd/index.html
delete mode 100755 docs/0.15.0/parseMangledSwiftSymbol(_:isType:)-3be6b73/index.html
delete mode 100755 docs/0.15.0/parseMangledSwiftSymbol(_:isType:symbolicReferenceResolver:)-111617a/index.html
delete mode 100755 docs/0.15.0/reset(_:)-2a0feaf/index.html
delete mode 100755 docs/0.15.0/sequence(of:)-c40bb93/index.html
delete mode 100755 docs/0.15.0/sequence(of:)-d9da3e4/index.html
delete mode 100755 docs/0.15.0/swizzleTestFailer(_:)-d923326/index.html
delete mode 100755 docs/0.15.0/twice-f36cfd6/index.html
delete mode 100755 docs/0.15.0/useDefaultValues(from:on:)-5df93fa/index.html
delete mode 100755 docs/0.15.0/useDefaultValues(from:on:)-7eb6cc5/index.html
delete mode 100755 docs/0.15.0/verify(_:file:line:)-a722fba/index.html
delete mode 100755 docs/0.16.0/ArgumentCaptor-1017688/index.html
delete mode 100755 docs/0.16.0/ArgumentMatcher-f013d1a/index.html
delete mode 100755 docs/0.16.0/CountMatcher-4be5ae3/index.html
delete mode 100755 docs/0.16.0/Declaration-f6338ac/index.html
delete mode 100755 docs/0.16.0/FunctionDeclaration-2ccea11/index.html
delete mode 100755 docs/0.16.0/ImplementationProvider-c664b1e/index.html
delete mode 100755 docs/0.16.0/MKBFail(_:isFatal:file:line:)-c41bd8d/index.html
delete mode 100755 docs/0.16.0/Mock-28ffcc3/index.html
delete mode 100755 docs/0.16.0/MockMetadata-36657c4/index.html
delete mode 100755 docs/0.16.0/Mockable-9a5a67c/index.html
delete mode 100755 docs/0.16.0/MockingContext-c5faed5/index.html
delete mode 100755 docs/0.16.0/NonEscapingClosure-e61507c/index.html
delete mode 100755 docs/0.16.0/OrderedVerificationOptions-77823cc/index.html
delete mode 100755 docs/0.16.0/PropertyGetterDeclaration-db9ea0d/index.html
delete mode 100755 docs/0.16.0/PropertySetterDeclaration-7cfb3cc/index.html
delete mode 100755 docs/0.16.0/Providable-7bc5aa7/index.html
delete mode 100755 docs/0.16.0/SourceLocation-656fd60/index.html
delete mode 100755 docs/0.16.0/StaticMock-882efeb/index.html
delete mode 100755 docs/0.16.0/StubbingContext-794fb76/index.html
delete mode 100755 docs/0.16.0/StubbingManager-761d798/index.html
delete mode 100755 docs/0.16.0/StubbingManager_TransitionStrategy-9f44b8f/index.html
delete mode 100755 docs/0.16.0/SubscriptDeclaration-38e94f4/index.html
delete mode 100755 docs/0.16.0/SubscriptGetterDeclaration-2324199/index.html
delete mode 100755 docs/0.16.0/SubscriptSetterDeclaration-a66f358/index.html
delete mode 100755 docs/0.16.0/TestFailer-4ae7a4d/index.html
delete mode 100755 docs/0.16.0/ThrowingFunctionDeclaration-9b512dc/index.html
delete mode 100755 docs/0.16.0/ValueProvider-54037ad/index.html
delete mode 100755 docs/0.16.0/VariableDeclaration-c075015/index.html
delete mode 100755 docs/0.16.0/VerificationManager-94d5cc8/index.html
delete mode 100755 docs/0.16.0/all.css
delete mode 100755 docs/0.16.0/any(_:)-da61986/index.html
delete mode 100755 docs/0.16.0/any(_:containing:)-0e18f78/index.html
delete mode 100755 docs/0.16.0/any(_:containing:)-365e26e/index.html
delete mode 100755 docs/0.16.0/any(_:count:)-860fd11/index.html
delete mode 100755 docs/0.16.0/any(_:keys:)-e7f89d4/index.html
delete mode 100755 docs/0.16.0/any(_:of:)-89cb3ec/index.html
delete mode 100755 docs/0.16.0/any(_:of:)-e376f19/index.html
delete mode 100755 docs/0.16.0/any(_:where:)-ea2d92e/index.html
delete mode 100755 docs/0.16.0/around(_:tolerance:)-831b19f/index.html
delete mode 100755 docs/0.16.0/atLeast(_:)-c832002/index.html
delete mode 100755 docs/0.16.0/atMost(_:)-a2b82d3/index.html
delete mode 100755 docs/0.16.0/between(_:)-cfca747/index.html
delete mode 100755 docs/0.16.0/clearDefaultValues(on:)-112773d/index.html
delete mode 100755 docs/0.16.0/clearInvocations(on:)-4120e8f/index.html
delete mode 100755 docs/0.16.0/clearStubs(on:)-f985ed7/index.html
delete mode 100755 docs/0.16.0/eventually(_:_:)-28d4191/index.html
delete mode 100755 docs/0.16.0/exactly(_:)-47abdfc/index.html
delete mode 100755 docs/0.16.0/finiteSequence(of:)-9390bb3/index.html
delete mode 100755 docs/0.16.0/finiteSequence(of:)-ff3ed8b/index.html
delete mode 100755 docs/0.16.0/given(_:)-05dd78f/index.html
delete mode 100755 docs/0.16.0/inOrder(with:file:line:_:)-3c038cb/index.html
delete mode 100755 docs/0.16.0/index.html
delete mode 100755 docs/0.16.0/lastSetValue(initial:)-576c55c/index.html
delete mode 100755 docs/0.16.0/loopingSequence(of:)-8ab9cb4/index.html
delete mode 100755 docs/0.16.0/loopingSequence(of:)-9da831b/index.html
delete mode 100755 docs/0.16.0/mock(_:)-b93ee0e/index.html
delete mode 100755 docs/0.16.0/never-9661ceb/index.html
delete mode 100755 docs/0.16.0/not(_:)-3f926b2/index.html
delete mode 100755 docs/0.16.0/not(_:)-cf99a2a/index.html
delete mode 100755 docs/0.16.0/notEmpty(_:)-3cab350/index.html
delete mode 100755 docs/0.16.0/notNil(_:)-42278eb/index.html
delete mode 100755 docs/0.16.0/once-3db83dd/index.html
delete mode 100755 docs/0.16.0/reset(_:)-2a0feaf/index.html
delete mode 100755 docs/0.16.0/sequence(of:)-c40bb93/index.html
delete mode 100755 docs/0.16.0/sequence(of:)-d9da3e4/index.html
delete mode 100755 docs/0.16.0/swizzleTestFailer(_:)-d923326/index.html
delete mode 100755 docs/0.16.0/twice-f36cfd6/index.html
delete mode 100755 docs/0.16.0/useDefaultValues(from:on:)-5df93fa/index.html
delete mode 100755 docs/0.16.0/useDefaultValues(from:on:)-7eb6cc5/index.html
delete mode 100755 docs/0.16.0/verify(_:file:line:)-a722fba/index.html
delete mode 100644 docs/0.17.0/ArgumentCaptor-94fb876/index.html
delete mode 100644 docs/0.17.0/ArgumentMatcher-1c43b93/index.html
delete mode 100644 docs/0.17.0/Array/index.html
delete mode 100644 docs/0.17.0/CountMatcher-6825dbf/index.html
delete mode 100644 docs/0.17.0/Declaration-61b39f6/index.html
delete mode 100644 docs/0.17.0/Dictionary/index.html
delete mode 100644 docs/0.17.0/FunctionDeclaration-9288d96/index.html
delete mode 100644 docs/0.17.0/ImplementationProvider-ebb9664/index.html
delete mode 100644 docs/0.17.0/MKBFail(_:isFatal:file:line:)-edcfdf0/index.html
delete mode 100644 docs/0.17.0/Mock-1448bd4/index.html
delete mode 100644 docs/0.17.0/MockMetadata-491926a/index.html
delete mode 100644 docs/0.17.0/Mockable-92ced01/index.html
delete mode 100644 docs/0.17.0/MockingContext-e8084fb/index.html
delete mode 100644 docs/0.17.0/NonEscapingClosure-ac8dd96/index.html
delete mode 100644 docs/0.17.0/Optional/index.html
delete mode 100644 docs/0.17.0/OrderedVerificationOptions-2ad9275/index.html
delete mode 100644 docs/0.17.0/PropertyGetterDeclaration-8ac0b54/index.html
delete mode 100644 docs/0.17.0/PropertySetterDeclaration-1a29109/index.html
delete mode 100644 docs/0.17.0/Providable-fd593f8/index.html
delete mode 100644 docs/0.17.0/Set/index.html
delete mode 100644 docs/0.17.0/SourceLocation-e12b876/index.html
delete mode 100644 docs/0.17.0/StaticMock-a04a7c2/index.html
delete mode 100644 docs/0.17.0/StubbingContext-c368434/index.html
delete mode 100644 docs/0.17.0/StubbingManager-c41b02a/index.html
delete mode 100644 docs/0.17.0/StubbingManager_TransitionStrategy-1e8f2be/index.html
delete mode 100644 docs/0.17.0/SubscriptDeclaration-c38cdc6/index.html
delete mode 100644 docs/0.17.0/SubscriptGetterDeclaration-f0cef1c/index.html
delete mode 100644 docs/0.17.0/SubscriptSetterDeclaration-e2c7a0d/index.html
delete mode 100644 docs/0.17.0/TestFailer-f9088cc/index.html
delete mode 100644 docs/0.17.0/ThrowingFunctionDeclaration-c3ccd38/index.html
delete mode 100644 docs/0.17.0/ValueProvider-242b058/index.html
delete mode 100644 docs/0.17.0/VariableDeclaration-f83ff6c/index.html
delete mode 100644 docs/0.17.0/VerificationManager-0d29384/index.html
delete mode 100644 docs/0.17.0/all.css
delete mode 100644 docs/0.17.0/any(_:)-57c9fd0/index.html
delete mode 100644 docs/0.17.0/any(_:containing:)-095611c/index.html
delete mode 100644 docs/0.17.0/any(_:containing:)-44dd020/index.html
delete mode 100644 docs/0.17.0/any(_:count:)-dbbc1fd/index.html
delete mode 100644 docs/0.17.0/any(_:keys:)-8ca4847/index.html
delete mode 100644 docs/0.17.0/any(_:of:)-0eb9154/index.html
delete mode 100644 docs/0.17.0/any(_:of:)-64e400e/index.html
delete mode 100644 docs/0.17.0/any(_:where:)-aeec51b/index.html
delete mode 100644 docs/0.17.0/around(_:tolerance:)-00be404/index.html
delete mode 100644 docs/0.17.0/atLeast(_:)-898a2b0/index.html
delete mode 100644 docs/0.17.0/atMost(_:)-3e1c32b/index.html
delete mode 100644 docs/0.17.0/between(_:)-d57ee49/index.html
delete mode 100644 docs/0.17.0/clearDefaultValues(on:)-d6625bc/index.html
delete mode 100644 docs/0.17.0/clearInvocations(on:)-c035ab0/index.html
delete mode 100644 docs/0.17.0/clearStubs(on:)-733a109/index.html
delete mode 100644 docs/0.17.0/eventually(_:_:)-4bc028a/index.html
delete mode 100644 docs/0.17.0/exactly(_:)-c366d42/index.html
delete mode 100644 docs/0.17.0/finiteSequence(of:)-4225436/index.html
delete mode 100644 docs/0.17.0/finiteSequence(of:)-b90973c/index.html
delete mode 100644 docs/0.17.0/given(_:)-8e1ce81/index.html
delete mode 100644 docs/0.17.0/inOrder(with:file:line:_:)-2287378/index.html
delete mode 100644 docs/0.17.0/index.html
delete mode 100644 docs/0.17.0/lastSetValue(initial:)-d6a1a47/index.html
delete mode 100644 docs/0.17.0/loopingSequence(of:)-8c11ab6/index.html
delete mode 100644 docs/0.17.0/loopingSequence(of:)-cc3f2b3/index.html
delete mode 100644 docs/0.17.0/mock(_:)-40a8117/index.html
delete mode 100644 docs/0.17.0/never-657a74c/index.html
delete mode 100644 docs/0.17.0/not(_:)-12c53a2/index.html
delete mode 100644 docs/0.17.0/not(_:)-90155c4/index.html
delete mode 100644 docs/0.17.0/notEmpty(_:)-42ce3f8/index.html
delete mode 100644 docs/0.17.0/notNil(_:)-4da033f/index.html
delete mode 100644 docs/0.17.0/once-dc7031f/index.html
delete mode 100644 docs/0.17.0/reset(_:)-5654439/index.html
delete mode 100644 docs/0.17.0/sequence(of:)-8b3c523/index.html
delete mode 100644 docs/0.17.0/sequence(of:)-af09516/index.html
delete mode 100644 docs/0.17.0/swizzleTestFailer(_:)-8147916/index.html
delete mode 100644 docs/0.17.0/twice-b13bfea/index.html
delete mode 100644 docs/0.17.0/useDefaultValues(from:on:)-3f9198a/index.html
delete mode 100644 docs/0.17.0/useDefaultValues(from:on:)-c891538/index.html
delete mode 100644 docs/0.17.0/verify(_:file:line:)-a5a6b2f/index.html
delete mode 100644 docs/0.18.0/AnyDeclaration-762b5df/index.html
delete mode 100644 docs/0.18.0/ArgumentCaptor-94fb876/index.html
delete mode 100644 docs/0.18.0/ArgumentMatcher-e2bb17a/index.html
delete mode 100644 docs/0.18.0/Array/index.html
delete mode 100644 docs/0.18.0/Context-67f9dcd/index.html
delete mode 100644 docs/0.18.0/CountMatcher-6825dbf/index.html
delete mode 100644 docs/0.18.0/Declaration-61b39f6/index.html
delete mode 100644 docs/0.18.0/Dictionary/index.html
delete mode 100644 docs/0.18.0/DynamicStubbingManager-824a4fd/index.html
delete mode 100644 docs/0.18.0/ErrorBox-1b2dcf7/index.html
delete mode 100644 docs/0.18.0/ForwardingContext-feff474/index.html
delete mode 100644 docs/0.18.0/FunctionDeclaration-9288d96/index.html
delete mode 100644 docs/0.18.0/ImplementationProvider-ebb9664/index.html
delete mode 100644 docs/0.18.0/InvocationRecorder-7d70b12/index.html
delete mode 100644 docs/0.18.0/InvocationRecorder_Mode-cf6cb72/index.html
delete mode 100644 docs/0.18.0/Mock-ad39d03/index.html
delete mode 100644 docs/0.18.0/MockMetadata-491926a/index.html
delete mode 100644 docs/0.18.0/Mockable-92ced01/index.html
delete mode 100644 docs/0.18.0/MockingContext-c31b095/index.html
delete mode 100644 docs/0.18.0/NSObjectProtocol/index.html
delete mode 100644 docs/0.18.0/NonEscapingClosure-ac8dd96/index.html
delete mode 100644 docs/0.18.0/ObjCErrorBox-ece9985/index.html
delete mode 100644 docs/0.18.0/ObjCInvocation-9ef7ffe/index.html
delete mode 100644 docs/0.18.0/Optional/index.html
delete mode 100644 docs/0.18.0/OrderedVerificationOptions-2ad9275/index.html
delete mode 100644 docs/0.18.0/PropertyGetterDeclaration-8ac0b54/index.html
delete mode 100644 docs/0.18.0/PropertySetterDeclaration-1a29109/index.html
delete mode 100644 docs/0.18.0/Providable-fd593f8/index.html
delete mode 100644 docs/0.18.0/ProxyContext-67feefc/index.html
delete mode 100644 docs/0.18.0/SelectorType-d2b8230/index.html
delete mode 100644 docs/0.18.0/Set/index.html
delete mode 100644 docs/0.18.0/SourceLocation-e12b876/index.html
delete mode 100644 docs/0.18.0/StaticMock-a04a7c2/index.html
delete mode 100644 docs/0.18.0/StaticStubbingManager-5a4489d/index.html
delete mode 100644 docs/0.18.0/StubbingContext-d729e61/index.html
delete mode 100644 docs/0.18.0/StubbingManager-c41b02a/index.html
delete mode 100644 docs/0.18.0/StubbingManager_TransitionStrategy-1e8f2be/index.html
delete mode 100644 docs/0.18.0/SubscriptDeclaration-c38cdc6/index.html
delete mode 100644 docs/0.18.0/SubscriptGetterDeclaration-f0cef1c/index.html
delete mode 100644 docs/0.18.0/SubscriptSetterDeclaration-e2c7a0d/index.html
delete mode 100644 docs/0.18.0/SwiftErrorBox-a9850af/index.html
delete mode 100644 docs/0.18.0/TestFailer-f9088cc/index.html
delete mode 100644 docs/0.18.0/ThrowingFunctionDeclaration-c3ccd38/index.html
delete mode 100644 docs/0.18.0/ValueProvider-242b058/index.html
delete mode 100644 docs/0.18.0/VariableDeclaration-f83ff6c/index.html
delete mode 100644 docs/0.18.0/VerificationManager-4f75443/index.html
delete mode 100644 docs/0.18.0/all.css
delete mode 100644 docs/0.18.0/any(_:)-04561d1/index.html
delete mode 100644 docs/0.18.0/any(_:)-57c9fd0/index.html
delete mode 100644 docs/0.18.0/any(_:containing:)-095611c/index.html
delete mode 100644 docs/0.18.0/any(_:containing:)-44dd020/index.html
delete mode 100644 docs/0.18.0/any(_:count:)-dbbc1fd/index.html
delete mode 100644 docs/0.18.0/any(_:keys:)-8ca4847/index.html
delete mode 100644 docs/0.18.0/any(_:of:)-0eb9154/index.html
delete mode 100644 docs/0.18.0/any(_:of:)-64e400e/index.html
delete mode 100644 docs/0.18.0/any(_:where:)-aeec51b/index.html
delete mode 100644 docs/0.18.0/any(_:where:)-faad7a5/index.html
delete mode 100644 docs/0.18.0/arg(_:at:)-e5b4d4c/index.html
delete mode 100644 docs/0.18.0/around(_:tolerance:)-00be404/index.html
delete mode 100644 docs/0.18.0/atLeast(_:)-898a2b0/index.html
delete mode 100644 docs/0.18.0/atMost(_:)-3e1c32b/index.html
delete mode 100644 docs/0.18.0/between(_:)-d57ee49/index.html
delete mode 100644 docs/0.18.0/clearDefaultValues(on:)-7b56f7e/index.html
delete mode 100644 docs/0.18.0/clearInvocations(on:)-3b83feb/index.html
delete mode 100644 docs/0.18.0/clearInvocations(on:)-c035ab0/index.html
delete mode 100644 docs/0.18.0/clearStubs(on:)-343b2f1/index.html
delete mode 100644 docs/0.18.0/clearStubs(on:)-733a109/index.html
delete mode 100644 docs/0.18.0/eventually(_:_:)-4bc028a/index.html
delete mode 100644 docs/0.18.0/exactly(_:)-c366d42/index.html
delete mode 100644 docs/0.18.0/fifthArg(_:)-b65d250/index.html
delete mode 100644 docs/0.18.0/finiteSequence(of:)-4225436/index.html
delete mode 100644 docs/0.18.0/finiteSequence(of:)-b90973c/index.html
delete mode 100644 docs/0.18.0/firstArg(_:)-ca2e527/index.html
delete mode 100644 docs/0.18.0/forward(to:)-28668e8/index.html
delete mode 100644 docs/0.18.0/forwardToSuper()-5c5eb13/index.html
delete mode 100644 docs/0.18.0/fourthArg(_:)-17b6638/index.html
delete mode 100644 docs/0.18.0/given(_:)-8aeefd4/index.html
delete mode 100644 docs/0.18.0/given(_:)-a96595c/index.html
delete mode 100644 docs/0.18.0/inOrder(with:file:line:_:)-2287378/index.html
delete mode 100644 docs/0.18.0/index.html
delete mode 100644 docs/0.18.0/lastSetValue(initial:)-d6a1a47/index.html
delete mode 100644 docs/0.18.0/loopingSequence(of:)-8c11ab6/index.html
delete mode 100644 docs/0.18.0/loopingSequence(of:)-cc3f2b3/index.html
delete mode 100644 docs/0.18.0/mock(_:)-40a8117/index.html
delete mode 100644 docs/0.18.0/mock(_:)-b58cf6a/index.html
delete mode 100644 docs/0.18.0/never-657a74c/index.html
delete mode 100644 docs/0.18.0/not(_:)-12c53a2/index.html
delete mode 100644 docs/0.18.0/not(_:)-90155c4/index.html
delete mode 100644 docs/0.18.0/notEmpty(_:)-42ce3f8/index.html
delete mode 100644 docs/0.18.0/notNil(_:)-4c25f3f/index.html
delete mode 100644 docs/0.18.0/notNil(_:)-4da033f/index.html
delete mode 100644 docs/0.18.0/once-dc7031f/index.html
delete mode 100644 docs/0.18.0/reset(_:)-5654439/index.html
delete mode 100644 docs/0.18.0/reset(_:)-76ccf89/index.html
delete mode 100644 docs/0.18.0/secondArg(_:)-39c95e2/index.html
delete mode 100644 docs/0.18.0/sequence(of:)-8b3c523/index.html
delete mode 100644 docs/0.18.0/sequence(of:)-af09516/index.html
delete mode 100644 docs/0.18.0/swizzleTestFailer(_:)-8147916/index.html
delete mode 100644 docs/0.18.0/thirdArg(_:)-4eaa586/index.html
delete mode 100644 docs/0.18.0/twice-b13bfea/index.html
delete mode 100644 docs/0.18.0/verify(_:file:line:)-023a535/index.html
delete mode 100644 docs/0.18.0/verify(_:file:line:)-a5a6b2f/index.html
delete mode 100644 docs/0.18.0/~>-561b2ad/index.html
create mode 100644 docs/Mockingbird.docc/Info.plist
delete mode 100644 docs/images/mockingbird-hero-image.png
delete mode 100644 docs/index.html
delete mode 100644 docs/latest/index.html
delete mode 160000 docs/swift-doc
diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644
index b2d786b4..00000000
--- a/.gitmodules
+++ /dev/null
@@ -1,3 +0,0 @@
-[submodule "docs/swift-doc"]
- path = docs/swift-doc
- url = https://github.com/andrewchang-bird/swift-doc
diff --git a/docs/0.14.0/ArgumentCaptor-1017688/index.html b/docs/0.14.0/ArgumentCaptor-1017688/index.html
deleted file mode 100755
index 48df4e27..00000000
--- a/docs/0.14.0/ArgumentCaptor-1017688/index.html
+++ /dev/null
@@ -1,181 +0,0 @@
-
-
-
-
-
- Mockingbird - ArgumentCaptor
-
-
-
-
-
-
- Mockingbird
-
- Documentation
-
- 0.14.0
-
-
-
-
-
-
-
-
-
A type that can provide concrete instances of itself.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
-
-
-
-
-
-
Requirements
-
-
-
- createInstance()
-
-
staticfunccreateInstance() -> Self?
-
-
Create a concrete instance of this type, or nil if no concrete instance is available.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.getName()).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-
-
Implementation providers usually return multiple values, so when using chained stubbing it's
-necessary to specify a transition strategy that defines when to go to the next stub.
-
-
given(bird.getName())
- .willReturn(lastSetValue(initial: ""), transition: .after(2))
- .willReturn("Sterling")
-
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letbird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types.
Value providers can be composed hierarchically by adding subproviders. Providers added later
-have higher precedence.
-
-
varvalueProvider = ValueProvider()
-
-// Add a preset value provider as a subprovider.
-valueProvider.addSubprovider(.standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-// Add a custom value provider a subprovider.
-varstringProvider = ValueProvider()
-stringProvider.register("Ryan", for: String.self)
-valueProvider.addSubprovider(stringProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
-
Register a Providable type used to provide values for generic types.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
V.Type
-
A Providable type to register.
-
-
-
-
-
-
-
- remove(_:)
-
-
mutatingpublicfuncremove<T>(_type: T.Type)
-
-
Remove a registered value for a given type.
-
-
-
-
Previously registered values can be removed from the top-level value provider. This does not
-affect values provided by subproviders.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-// Override the subprovider value
-valueProvider.register("Ryan", for: String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
-
-// Remove the registered value
-valueProvider.remove(String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
T.Type
-
The type to remove a previously registered value for.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
publicfuncany<T: Collection>(_type: T.Type = T.self, containingvalues: T.Element) -> T
-
-
Matches any collection containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match collections that contain all specified
-values.
Matches any dictionary containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match dictionaries that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, countcountMatcher: CountMatcher) -> T
-
-
Matches any collection with a specific number of elements.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(count:) to match collections with a specific number of elements.
Matches any dictionary containing all of the keys.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(keys:) to match dictionaries that contain all specified keys.
publicfuncany<T: AnyObject>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values identical to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match objects identical to one or more of the specified
-values.
publicfuncany<T: Equatable>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values equal to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match Equatable argument values equal to one or more of
-the specified values.
-
-
given(bird.canChirp(volume: any(of: 1, 3)))
- .willReturn(true)
-
-given(bird.canChirp(volume: any(of: 2, 4)))
- .willReturn(false)
-
-print(bird.canChirp(volume: 1)) // Prints "true"
-print(bird.canChirp(volume: 2)) // Prints "false"
-print(bird.canChirp(volume: 3)) // Prints "true"
-print(bird.canChirp(volume: 4)) // Prints "false"
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
-
-
// Value type not explicitly conforming to `Equatable`
-structFruit {
- letsize: Int
-}
-
-protocolBird {
- funceat(_fruit: Fruit)
-}
-
-given(bird.eat(any(where: { $0.size < 100 })))
- .will { print($0.size) }
-
-letapple = Fruit(size: 42)
-bird.eat(apple) // Prints "42"
-
-letpear = Fruit(size: 9001)
-bird.eat(pear) // Error: Missing stubbed implementation
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
publicfuncaround<T: FloatingPoint>(_value: T, tolerance: T) -> T
-
-
Matches floating point arguments within some tolerance.
-
-
-
-
Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
The atLeast count matcher can be used to verify that the actual number of invocations received
-by a mock is greater than or equal to the expected number of invocations.
The atMost count matcher can be used to verify that the actual number of invocations received
-by a mock is less than or equal to the expected number of invocations.
The between count matcher can be used to verify that the actual number of invocations received
-by a mock is within an inclusive range of expected invocations.
-
-
// Given two invocations (n = 2)
-bird.fly()
-bird.fly()
-
-verify(bird.fly()).wasCalled(between(1...2)) // Passes
-verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
-
-
You can combine count matchers with adverbial counts for improved readability.
Provide one or more values which will be returned sequentially for each invocation. The stub
-will be invalidated if the number of invocations is greater than the number of values provided.
Provide one or more implementations which will be returned sequentially for each invocation. The
-stub will be invalidated if the number of invocations is greater than the number of
-implementations provided.
An inOrder block is resolved greedily, such that each verification must happen from the oldest
-remaining unsatisfied invocations.
-
-
// Given these unsatisfied invocations
-bird.fly()
-bird.fly()
-bird.chirp()
-
-// Greedy strategy _must_ start from the first `fly`
-inOrder {
- verify(bird.fly()).wasCalled(twice)
- verify(bird.chirp()).wasCalled()
-}
-
-// Non-greedy strategy can start from the second `fly`
-inOrder {
- verify(bird.fly()).wasCalled()
- verify(bird.chirp()).wasCalled()
-}
-
Provide one or more values which will be returned sequentially for each invocation. The sequence
-will loop from the beginning if the number of invocations is greater than the number of values
-provided.
-
-
given(bird.getName())
- .willReturn(loopingSequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-sequence will loop from the beginning if the number of invocations is greater than the number of
-implementations provided.
-
-
given(bird.getName()).willReturn(loopingSequence(of: {
- returnBool.random() ? "Ryan" : "Meisters"
-}, {
- returnBool.random() ? "Sterling" : "Hackley"
-}))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Meisters"
-print(bird.name) // Prints "Hackley"
-
publicfuncnotEmpty<T: Collection>(_type: T.Type = T.self) -> T
-
-
Matches any collection with at least one element.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notEmpty to match collections with one or more elements.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
Provide one or more implementations which will be returned sequentially for each invocation. The
-last implementation will be used if the number of invocations is greater than the number of
-implementations provided.
Provide one or more values which will be returned sequentially for each invocation. The last
-value will be used if the number of invocations is greater than the number of values provided.
-
-
given(bird.getName())
- .willReturn(sequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-
Start returning default values for unstubbed methods on a single mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-useDefaultValues(from: valueProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mock
-
Mock
-
A mock that should start using the value provider.
Start returning default values for unstubbed methods on multiple mocks.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letanotherBird = mock(Bird.self)
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-print(bird.name) // Prints ""
-print(anotherBird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-
-useDefaultValues(from: valueProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints ""
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mocks
-
[Mock]
-
A list of mocks that should start using the value provider.
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
A type that can provide concrete instances of itself.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
-
-
-
-
-
-
Requirements
-
-
-
- createInstance()
-
-
staticfunccreateInstance() -> Self?
-
-
Create a concrete instance of this type, or nil if no concrete instance is available.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.getName()).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-
-
Implementation providers usually return multiple values, so when using chained stubbing it's
-necessary to specify a transition strategy that defines when to go to the next stub.
-
-
given(bird.getName())
- .willReturn(lastSetValue(initial: ""), transition: .after(2))
- .willReturn("Sterling")
-
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letbird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types.
Value providers can be composed by adding values from another provider. Values in the other
-provider have precedence and will overwrite existing values in this provider.
-
-
varvalueProvider = ValueProvider()
-valueProvider.add(.standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
other
-
Self
-
A value provider to combine.
-
-
-
-
-
-
-
- adding(_:)
-
-
publicfuncadding(_other: Self) -> Self
-
-
Returns a new value provider containing the values from both providers.
-
-
-
-
Value providers can be composed by adding values from another provider. Values in the added
-provider have precendence over those in base provider.
-
-
letvalueProvider = ValueProvider.collectionsProvider.adding(.primitivesProvider)
-print(valueProvider.provideValue(for: [Bool].self)) // Prints []
-print(valueProvider.provideValue(for: Int.self)) // Prints 0
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
other
-
Self
-
A value provider to combine.
-
-
-
-
-
Returns
-
A new value provider with the values of lhs and rhs.
-
-
-
-
- +(lhs:rhs:)
-
-
staticpublicfunc +(lhs: Self, rhs: Self) -> Self
-
-
Returns a new value provider containing the values from both providers.
-
-
-
-
Value providers can be composed by adding values from other providers. Values in the second
-provider have precendence over those in first provider.
-
-
letvalueProvider = .collectionsProvider + .primitivesProvider
-print(valueProvider.provideValue(for: [Bool].self)) // Prints []
-print(valueProvider.provideValue(for: Int.self)) // Prints 0
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
lhs
-
Self
-
A value provider.
-
-
-
-
rhs
-
Self
-
A value provider.
-
-
-
-
-
Returns
-
A new value provider with the values of lhs and rhs.
Register a Providable type used to provide values for generic types.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
T.Type
-
A Providable type to register.
-
-
-
-
-
-
-
- remove(_:)
-
-
mutatingpublicfuncremove<T>(_type: T.Type)
-
-
Remove a registered value for a given type.
-
-
-
-
Previously registered values can be removed from the top-level value provider. This does not
-affect values provided by subproviders.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-// Override the subprovider value
-valueProvider.register("Ryan", for: String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
-
-// Remove the registered value
-valueProvider.remove(String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
T.Type
-
The type to remove a previously registered value for.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
publicfuncany<T: Collection>(_type: T.Type = T.self, containingvalues: T.Element) -> T
-
-
Matches any collection containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match collections that contain all specified
-values.
Matches any dictionary containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match dictionaries that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, countcountMatcher: CountMatcher) -> T
-
-
Matches any collection with a specific number of elements.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(count:) to match collections with a specific number of elements.
Matches any dictionary containing all of the keys.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(keys:) to match dictionaries that contain all specified keys.
publicfuncany<T: AnyObject>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values identical to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match objects identical to one or more of the specified
-values.
publicfuncany<T: Equatable>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values equal to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match Equatable argument values equal to one or more of
-the specified values.
-
-
given(bird.canChirp(volume: any(of: 1, 3)))
- .willReturn(true)
-
-given(bird.canChirp(volume: any(of: 2, 4)))
- .willReturn(false)
-
-print(bird.canChirp(volume: 1)) // Prints "true"
-print(bird.canChirp(volume: 2)) // Prints "false"
-print(bird.canChirp(volume: 3)) // Prints "true"
-print(bird.canChirp(volume: 4)) // Prints "false"
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
-
-
// Value type not explicitly conforming to `Equatable`
-structFruit {
- letsize: Int
-}
-
-protocolBird {
- funceat(_fruit: Fruit)
-}
-
-given(bird.eat(any(where: { $0.size < 100 })))
- .will { print($0.size) }
-
-letapple = Fruit(size: 42)
-bird.eat(apple) // Prints "42"
-
-letpear = Fruit(size: 9001)
-bird.eat(pear) // Error: Missing stubbed implementation
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
publicfuncaround<T: FloatingPoint>(_value: T, tolerance: T) -> T
-
-
Matches floating point arguments within some tolerance.
-
-
-
-
Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
The atLeast count matcher can be used to verify that the actual number of invocations received
-by a mock is greater than or equal to the expected number of invocations.
The atMost count matcher can be used to verify that the actual number of invocations received
-by a mock is less than or equal to the expected number of invocations.
The between count matcher can be used to verify that the actual number of invocations received
-by a mock is within an inclusive range of expected invocations.
-
-
// Given two invocations (n = 2)
-bird.fly()
-bird.fly()
-
-verify(bird.fly()).wasCalled(between(1...2)) // Passes
-verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
-
-
You can combine count matchers with adverbial counts for improved readability.
Provide one or more values which will be returned sequentially for each invocation. The stub
-will be invalidated if the number of invocations is greater than the number of values provided.
Provide one or more implementations which will be returned sequentially for each invocation. The
-stub will be invalidated if the number of invocations is greater than the number of
-implementations provided.
An inOrder block is resolved greedily, such that each verification must happen from the oldest
-remaining unsatisfied invocations.
-
-
// Given these unsatisfied invocations
-bird.fly()
-bird.fly()
-bird.chirp()
-
-// Greedy strategy _must_ start from the first `fly`
-inOrder {
- verify(bird.fly()).wasCalled(twice)
- verify(bird.chirp()).wasCalled()
-}
-
-// Non-greedy strategy can start from the second `fly`
-inOrder {
- verify(bird.fly()).wasCalled()
- verify(bird.chirp()).wasCalled()
-}
-
This is likely to be the primary entry point to this file. Pass a string containing a Swift mangled symbol or type, get a parsed SwiftSymbol structure which can then be directly examined or printed.
Pass a collection of UnicodeScalars containing a Swift mangled symbol or type, get a parsed SwiftSymbol structure which can then be directly examined or printed.
Provide one or more values which will be returned sequentially for each invocation. The sequence
-will loop from the beginning if the number of invocations is greater than the number of values
-provided.
-
-
given(bird.getName())
- .willReturn(loopingSequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-sequence will loop from the beginning if the number of invocations is greater than the number of
-implementations provided.
-
-
given(bird.getName()).willReturn(loopingSequence(of: {
- returnBool.random() ? "Ryan" : "Meisters"
-}, {
- returnBool.random() ? "Sterling" : "Hackley"
-}))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Meisters"
-print(bird.name) // Prints "Hackley"
-
@available(*, unavailable, message: "No generated mock for this type which might be resolved by building the test target (⇧⌘U)") publicfuncmock<T>(_type: T.Type) -> T
-
-
Returns a mock of a given type.
-
-
-
-
Initialized mocks can be passed in place of the original type. Protocol mocks do not require
-explicit initialization while class mocks should be created using initialize(…).
Generated mock types are suffixed with Mock and should not be coerced into their supertype.
-
-
letbird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
-letinferredBird = mock(Bird.self) // Type inference also works
-letcoerced: Bird = mock(Bird.self) // Avoid upcasting mocks
-
publicfuncnotEmpty<T: Collection>(_type: T.Type = T.self) -> T
-
-
Matches any collection with at least one element.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notEmpty to match collections with one or more elements.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
This is likely to be the primary entry point to this file. Pass a string containing a Swift mangled symbol or type, get a parsed SwiftSymbol structure which can then be directly examined or printed.
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
mangled
-
String
-
the string to be parsed ("isType` is false, the string should start with a Swift Symbol prefix, _T, _$S or $S).
-
-
-
-
isType
-
Bool
-
if true, no prefix is parsed and, on completion, the first item on the parse stack is returned.
-
-
-
-
-
Throws
-
a SwiftSymbolParseError error that contains parse position when the error occurred.
Pass a collection of UnicodeScalars containing a Swift mangled symbol or type, get a parsed SwiftSymbol structure which can then be directly examined or printed.
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
mangled
-
C
-
the collection of UnicodeScalars to be parsed ("isType` is false, the string should start with a Swift Symbol prefix, _T, _$S or $S).
-
-
-
-
isType
-
Bool
-
if true, no prefix is parsed and, on completion, the first item on the parse stack is returned.
-
-
-
-
-
Throws
-
a SwiftSymbolParseError error that contains parse position when the error occurred.
Provide one or more implementations which will be returned sequentially for each invocation. The
-last implementation will be used if the number of invocations is greater than the number of
-implementations provided.
Provide one or more values which will be returned sequentially for each invocation. The last
-value will be used if the number of invocations is greater than the number of values provided.
-
-
given(bird.getName())
- .willReturn(sequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-
Start returning default values for unstubbed methods on a single mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-useDefaultValues(from: valueProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mock
-
Mock
-
A mock that should start using the value provider.
Start returning default values for unstubbed methods on multiple mocks.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letanotherBird = mock(Bird.self)
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-print(bird.name) // Prints ""
-print(anotherBird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-
-useDefaultValues(from: valueProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints ""
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mocks
-
[Mock]
-
A list of mocks that should start using the value provider.
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
A type that can provide concrete instances of itself.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
-
-
-
-
-
-
Requirements
-
-
-
- createInstance()
-
-
staticfunccreateInstance() -> Self?
-
-
Create a concrete instance of this type, or nil if no concrete instance is available.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.getName()).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-
-
Implementation providers usually return multiple values, so when using chained stubbing it's
-necessary to specify a transition strategy that defines when to go to the next stub.
-
-
given(bird.getName())
- .willReturn(lastSetValue(initial: ""), transition: .after(2))
- .willReturn("Sterling")
-
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letbird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types.
Value providers can be composed by adding values from another provider. Values in the other
-provider have precedence and will overwrite existing values in this provider.
-
-
varvalueProvider = ValueProvider()
-valueProvider.add(.standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
other
-
Self
-
A value provider to combine.
-
-
-
-
-
-
-
- adding(_:)
-
-
publicfuncadding(_other: Self) -> Self
-
-
Returns a new value provider containing the values from both providers.
-
-
-
-
Value providers can be composed by adding values from another provider. Values in the added
-provider have precendence over those in base provider.
-
-
letvalueProvider = ValueProvider.collectionsProvider.adding(.primitivesProvider)
-print(valueProvider.provideValue(for: [Bool].self)) // Prints []
-print(valueProvider.provideValue(for: Int.self)) // Prints 0
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
other
-
Self
-
A value provider to combine.
-
-
-
-
-
Returns
-
A new value provider with the values of lhs and rhs.
-
-
-
-
- +(lhs:rhs:)
-
-
staticpublicfunc +(lhs: Self, rhs: Self) -> Self
-
-
Returns a new value provider containing the values from both providers.
-
-
-
-
Value providers can be composed by adding values from other providers. Values in the second
-provider have precendence over those in first provider.
-
-
letvalueProvider = .collectionsProvider + .primitivesProvider
-print(valueProvider.provideValue(for: [Bool].self)) // Prints []
-print(valueProvider.provideValue(for: Int.self)) // Prints 0
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
lhs
-
Self
-
A value provider.
-
-
-
-
rhs
-
Self
-
A value provider.
-
-
-
-
-
Returns
-
A new value provider with the values of lhs and rhs.
Register a Providable type used to provide values for generic types.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
T.Type
-
A Providable type to register.
-
-
-
-
-
-
-
- remove(_:)
-
-
mutatingpublicfuncremove<T>(_type: T.Type)
-
-
Remove a registered value for a given type.
-
-
-
-
Previously registered values can be removed from the top-level value provider. This does not
-affect values provided by subproviders.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-// Override the subprovider value
-valueProvider.register("Ryan", for: String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints "Ryan"
-
-// Remove the registered value
-valueProvider.remove(String.self)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
type
-
T.Type
-
The type to remove a previously registered value for.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
publicfuncany<T: Collection>(_type: T.Type = T.self, containingvalues: T.Element) -> T
-
-
Matches any collection containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match collections that contain all specified
-values.
Matches any dictionary containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match dictionaries that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, countcountMatcher: CountMatcher) -> T
-
-
Matches any collection with a specific number of elements.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(count:) to match collections with a specific number of elements.
Matches any dictionary containing all of the keys.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(keys:) to match dictionaries that contain all specified keys.
publicfuncany<T: AnyObject>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values identical to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match objects identical to one or more of the specified
-values.
publicfuncany<T: Equatable>(_type: T.Type = T.self, ofobjects: T) -> T
-
-
Matches argument values equal to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match Equatable argument values equal to one or more of
-the specified values.
-
-
given(bird.canChirp(volume: any(of: 1, 3)))
- .willReturn(true)
-
-given(bird.canChirp(volume: any(of: 2, 4)))
- .willReturn(false)
-
-print(bird.canChirp(volume: 1)) // Prints "true"
-print(bird.canChirp(volume: 2)) // Prints "false"
-print(bird.canChirp(volume: 3)) // Prints "true"
-print(bird.canChirp(volume: 4)) // Prints "false"
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
-
-
// Value type not explicitly conforming to `Equatable`
-structFruit {
- letsize: Int
-}
-
-protocolBird {
- funceat(_fruit: Fruit)
-}
-
-given(bird.eat(any(where: { $0.size < 100 })))
- .will { print($0.size) }
-
-letapple = Fruit(size: 42)
-bird.eat(apple) // Prints "42"
-
-letpear = Fruit(size: 9001)
-bird.eat(pear) // Error: Missing stubbed implementation
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
publicfuncaround<T: FloatingPoint>(_value: T, tolerance: T) -> T
-
-
Matches floating point arguments within some tolerance.
-
-
-
-
Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
The atLeast count matcher can be used to verify that the actual number of invocations received
-by a mock is greater than or equal to the expected number of invocations.
The atMost count matcher can be used to verify that the actual number of invocations received
-by a mock is less than or equal to the expected number of invocations.
The between count matcher can be used to verify that the actual number of invocations received
-by a mock is within an inclusive range of expected invocations.
-
-
// Given two invocations (n = 2)
-bird.fly()
-bird.fly()
-
-verify(bird.fly()).wasCalled(between(1...2)) // Passes
-verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
-
-
You can combine count matchers with adverbial counts for improved readability.
Provide one or more values which will be returned sequentially for each invocation. The stub
-will be invalidated if the number of invocations is greater than the number of values provided.
Provide one or more implementations which will be returned sequentially for each invocation. The
-stub will be invalidated if the number of invocations is greater than the number of
-implementations provided.
An inOrder block is resolved greedily, such that each verification must happen from the oldest
-remaining unsatisfied invocations.
-
-
// Given these unsatisfied invocations
-bird.fly()
-bird.fly()
-bird.chirp()
-
-// Greedy strategy _must_ start from the first `fly`
-inOrder {
- verify(bird.fly()).wasCalled(twice)
- verify(bird.chirp()).wasCalled()
-}
-
-// Non-greedy strategy can start from the second `fly`
-inOrder {
- verify(bird.fly()).wasCalled()
- verify(bird.chirp()).wasCalled()
-}
-
Provide one or more values which will be returned sequentially for each invocation. The sequence
-will loop from the beginning if the number of invocations is greater than the number of values
-provided.
-
-
given(bird.getName())
- .willReturn(loopingSequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-sequence will loop from the beginning if the number of invocations is greater than the number of
-implementations provided.
-
-
given(bird.getName()).willReturn(loopingSequence(of: {
- returnBool.random() ? "Ryan" : "Meisters"
-}, {
- returnBool.random() ? "Sterling" : "Hackley"
-}))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Meisters"
-print(bird.name) // Prints "Hackley"
-
@available(*, unavailable, message: "No generated mock for this type which might be resolved by building the test target (⇧⌘U)") publicfuncmock<T>(_type: T.Type) -> T
-
-
Returns a mock of a given type.
-
-
-
-
Initialized mocks can be passed in place of the original type. Protocol mocks do not require
-explicit initialization while class mocks should be created using initialize(…).
Generated mock types are suffixed with Mock and should not be coerced into their supertype.
-
-
letbird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
-letinferredBird = mock(Bird.self) // Type inference also works
-letcoerced: Bird = mock(Bird.self) // Avoid upcasting mocks
-
publicfuncnotEmpty<T: Collection>(_type: T.Type = T.self) -> T
-
-
Matches any collection with at least one element.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notEmpty to match collections with one or more elements.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
Provide one or more implementations which will be returned sequentially for each invocation. The
-last implementation will be used if the number of invocations is greater than the number of
-implementations provided.
Provide one or more values which will be returned sequentially for each invocation. The last
-value will be used if the number of invocations is greater than the number of values provided.
-
-
given(bird.getName())
- .willReturn(sequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-
Start returning default values for unstubbed methods on a single mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-useDefaultValues(from: valueProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mock
-
Mock
-
A mock that should start using the value provider.
Start returning default values for unstubbed methods on multiple mocks.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letanotherBird = mock(Bird.self)
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-print(bird.name) // Prints ""
-print(anotherBird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-
-useDefaultValues(from: valueProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints ""
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mocks
-
[Mock]
-
A list of mocks that should start using the value provider.
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
Adds a value provider returning default values for unstubbed methods to this mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized
-mock. Mockingbird provides preset value providers which are guaranteed to be backwards
-compatible, such as .standardProvider.
-
-
bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for
-how to provide "wildcard" instances for generic types.
A type that can provide concrete instances of itself.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
-
-
-
-
-
-
Requirements
-
-
-
- createInstance()
-
-
-
staticfunccreateInstance() -> Self?
-
-
-
Create a concrete instance of this type, or nil if no concrete instance is available.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.getName()).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-
-
Implementation providers usually return multiple values, so when using chained stubbing it's
-necessary to specify a transition strategy that defines when to go to the next stub.
-
-
given(bird.getName())
- .willReturn(lastSetValue(initial: ""), transition: .after(2))
- .willReturn("Sterling")
-
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letbird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types.
Value providers can be composed by adding values from another provider. Values in the other
-provider have precedence and will overwrite existing values in this provider.
-
-
varvalueProvider = ValueProvider()
-valueProvider.add(.standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
Register a Providable type used to provide values for generic types.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
Matches any dictionary containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match dictionaries that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, containingvalues: T.Element...) -> T
-
-
-
Matches any collection containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match collections that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, countcountMatcher: CountMatcher) -> T
-
-
-
Matches any collection with a specific number of elements.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(count:) to match collections with a specific number of elements.
Matches any dictionary containing all of the keys.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(keys:) to match dictionaries that contain all specified keys.
publicfuncany<T: AnyObject>(_type: T.Type = T.self, ofobjects: T...) -> T
-
-
-
Matches argument values identical to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match objects identical to one or more of the specified
-values.
publicfuncany<T: Equatable>(_type: T.Type = T.self, ofobjects: T...) -> T
-
-
-
Matches argument values equal to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match Equatable argument values equal to one or more of
-the specified values.
-
-
given(bird.canChirp(volume: any(of: 1, 3)))
- .willReturn(true)
-
-given(bird.canChirp(volume: any(of: 2, 4)))
- .willReturn(false)
-
-print(bird.canChirp(volume: 1)) // Prints "true"
-print(bird.canChirp(volume: 2)) // Prints "false"
-print(bird.canChirp(volume: 3)) // Prints "true"
-print(bird.canChirp(volume: 4)) // Prints "false"
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
-
-
// Value type not explicitly conforming to `Equatable`
-structFruit {
- letsize: Int
-}
-
-protocolBird {
- funceat(_fruit: Fruit)
-}
-
-given(bird.eat(any(where: { $0.size < 100 })))
- .will { print($0.size) }
-
-letapple = Fruit(size: 42)
-bird.eat(apple) // Prints "42"
-
-letpear = Fruit(size: 9001)
-bird.eat(pear) // Error: Missing stubbed implementation
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
publicfuncaround<T: FloatingPoint>(_value: T, tolerance: T) -> T
-
-
-
Matches floating point arguments within some tolerance.
-
-
-
-
Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
The atLeast count matcher can be used to verify that the actual number of invocations received
-by a mock is greater than or equal to the expected number of invocations.
The atMost count matcher can be used to verify that the actual number of invocations received
-by a mock is less than or equal to the expected number of invocations.
The between count matcher can be used to verify that the actual number of invocations received
-by a mock is within an inclusive range of expected invocations.
-
-
// Given two invocations (n = 2)
-bird.fly()
-bird.fly()
-
-verify(bird.fly()).wasCalled(between(1...2)) // Passes
-verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
-
-
You can combine count matchers with adverbial counts for improved readability.
Provide one or more implementations which will be returned sequentially for each invocation. The
-stub will be invalidated if the number of invocations is greater than the number of
-implementations provided.
Provide one or more values which will be returned sequentially for each invocation. The stub
-will be invalidated if the number of invocations is greater than the number of values provided.
An inOrder block is resolved greedily, such that each verification must happen from the oldest
-remaining unsatisfied invocations.
-
-
// Given these unsatisfied invocations
-bird.fly()
-bird.fly()
-bird.chirp()
-
-// Greedy strategy _must_ start from the first `fly`
-inOrder {
- verify(bird.fly()).wasCalled(twice)
- verify(bird.chirp()).wasCalled()
-}
-
-// Non-greedy strategy can start from the second `fly`
-inOrder {
- verify(bird.fly()).wasCalled()
- verify(bird.chirp()).wasCalled()
-}
-
Provide one or more values which will be returned sequentially for each invocation. The sequence
-will loop from the beginning if the number of invocations is greater than the number of values
-provided.
-
-
given(bird.getName())
- .willReturn(loopingSequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-sequence will loop from the beginning if the number of invocations is greater than the number of
-implementations provided.
-
-
given(bird.getName()).willReturn(loopingSequence(of: {
- returnBool.random() ? "Ryan" : "Meisters"
-}, {
- returnBool.random() ? "Sterling" : "Hackley"
-}))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Meisters"
-print(bird.name) // Prints "Hackley"
-
@available(*, unavailable, message: "No generated mock for this type which might be resolved by building the test target (⇧⌘U)")
-publicfuncmock<T>(_type: T.Type) -> T
-
-
-
Returns a mock of a given type.
-
-
-
-
Initialized mocks can be passed in place of the original type. Protocol mocks do not require
-explicit initialization while class mocks should be created using initialize(…).
Generated mock types are suffixed with Mock and should not be coerced into their supertype.
-
-
letbird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
-letinferredBird = mock(Bird.self) // Type inference also works
-letcoerced: Bird = mock(Bird.self) // Avoid upcasting mocks
-
publicfuncnotEmpty<T: Collection>(_type: T.Type = T.self) -> T
-
-
-
Matches any collection with at least one element.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notEmpty to match collections with one or more elements.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
Provide one or more values which will be returned sequentially for each invocation. The last
-value will be used if the number of invocations is greater than the number of values provided.
-
-
given(bird.getName())
- .willReturn(sequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-last implementation will be used if the number of invocations is greater than the number of
-implementations provided.
Start returning default values for unstubbed methods on a single mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-useDefaultValues(from: valueProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: bird)
-print(bird.name) // Prints "Ryan"
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mock
-
Mock
-
A mock that should start using the value provider.
Start returning default values for unstubbed methods on multiple mocks.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.getName()` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letanotherBird = mock(Bird.self)
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-print(bird.name) // Prints ""
-print(anotherBird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for how
-to provide "wildcard" instances for generic types.
-
-
varvalueProvider = ValueProvider(from: .standardProvider)
-valueProvider.register("Ryan", for: String.self)
-
-useDefaultValues(from: valueProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints "Ryan"
-
-
Values from concrete stubs always have a higher precedence than default values.
-
-
given(bird.getName()) ~> "Ryan"
-print(bird.name) // Prints "Ryan"
-
-useDefaultValues(from: .standardProvider, on: [bird, anotherBird])
-
-print(bird.name) // Prints "Ryan"
-print(anotherBird.name) // Prints ""
-
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
valueProvider
-
ValueProvider
-
A value provider to add.
-
-
-
-
mocks
-
[Mock]
-
A list of mocks that should start using the value provider.
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
An intermediate object used for stubbing Objective-C declarations returned by given.
-
-
-
-
Stubbed implementations are type erased to allow Swift to apply arguments with minimal type
-information. See StubbingContext+ObjCReturnValue for more context.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Adds a value provider returning default values for unstubbed methods to this mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.name` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized
-mock. Mockingbird provides preset value providers which are guaranteed to be backwards
-compatible, such as .standardProvider.
-
-
bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for
-how to provide "wildcard" instances for generic types.
Create a partial mock, forwarding all calls without an explicit stub to the superclass.
-
-
-
-
Use forwardCallsToSuper on class mocks to call the superclass implementation. Superclass
-forwarding persists until removed with clearStubs or shadowed by a forwarding target that
-was added afterwards.
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
-
-
// Not a class
-protocolAbstractBird {
- varname: String { get }
-}
-
-letbird = mock(AbstractBird.self)
-bird.forwardCallsToSuper()
-print(bird.name) // Error: Missing stubbed implementation
-
-
-
Returns
-
A partial mock using the superclass to handle invocations.
Create a partial mock, forwarding all calls without an explicit stub to an object.
-
-
-
-
Objects are strongly referenced and receive proxed invocations until removed with
-clearStubs. Targets added afterwards have a higher precedence and only pass calls down the forwarding chain if unable handle the invocation, such as when the target is unrelated to the
-mocked type.
-
-
classCrow: Bird {
- letname: String
- init(name: String) { self.name = name }
-}
-
-letbird = mock(Bird.self)
-bird.forwardCalls(to: Crow(name: "Ryan"))
-print(bird.name) // Prints "Ryan"
-
-// Additional targets take precedence
-bird.forwardCalls(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Sterling"
-
-
Concrete stubs always have a higher priority than forwarding targets, regardless of the order
-they were added.
-
-
given(bird.name).willReturn("Ryan")
-bird.forwardCalls(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Ryan"
-
-
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
Create a partial mock, forwarding all calls without an explicit stub to the superclass.
-
-
-
-
Use forwardCallsToSuper on class mocks to call the superclass implementation. Superclass
-forwarding persists until removed with clearStubs or shadowed by a forwarding target that
-was added afterwards.
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
-
-
// Not a class
-protocolAbstractBird {
- varname: String { get }
-}
-
-letbird = mock(AbstractBird.self)
-bird.forwardCallsToSuper()
-print(bird.name) // Error: Missing stubbed implementation
-
-
-
Returns
-
A partial mock using the superclass to handle invocations.
Create a partial mock, forwarding all calls without an explicit stub to an object.
-
-
-
-
Objects are strongly referenced and receive proxed invocations until removed with
-clearStubs. Targets added afterwards have a higher precedence and only pass calls down the forwarding chain if unable handle the invocation, such as when the target is unrelated to the
-mocked type.
-
-
classCrow: Bird {
- letname: String
- init(name: String) { self.name = name }
-}
-
-letbird = mock(Bird.self)
-bird.forwardCalls(to: Crow(name: "Ryan"))
-print(bird.name) // Prints "Ryan"
-
-// Additional targets take precedence
-bird.forwardCalls(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Sterling"
-
-
Concrete stubs always have a higher priority than forwarding targets, regardless of the order
-they were added.
-
-
given(bird.name).willReturn("Ryan")
-bird.forwardCalls(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Ryan"
-
-
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
Adds a value provider returning default values for unstubbed methods to this mock.
-
-
-
-
Mocks are strict by default, meaning that calls to unstubbed methods will trigger a test
-failure. Methods returning Void do not need to be stubbed in strict mode.
-
-
letbird = mock(Bird.self)
-print(bird.name) // Fails because `bird.name` is not stubbed
-bird.fly() // Okay because `fly()` has a `Void` return type
-
-
To return default values for unstubbed methods, use a ValueProvider with the initialized
-mock. Mockingbird provides preset value providers which are guaranteed to be backwards
-compatible, such as .standardProvider.
-
-
bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types. See Providable for
-how to provide "wildcard" instances for generic types.
A type that can provide concrete instances of itself.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-
-
-
-
-
-
-
-
Requirements
-
-
-
- createInstance()
-
-
-
staticfunccreateInstance() -> Self?
-
-
-
Create a concrete instance of this type, or nil if no concrete instance is available.
Forward calls for a specific declaration to the superclass.
-
-
-
-
Use willForwardToSuper on class mock declarations to call the superclass implementation when
-receiving a matching invocation. Superclass forwarding persists until removed with
-clearStubs or shadowed by a forwarding target that was added afterwards.
Forward calls for a specific declaration to an object.
-
-
-
-
Objects are strongly referenced and receive forwarded invocations until removed with
-clearStubs. Targets added afterwards have a higher precedence and only pass calls down the
-forwarding chain if unable handle the invocation, such as when the target is unrelated to the
-mocked type.
-
-
classCrow: Bird {
- letname: String
- init(name: String) { self.name = name }
-}
-
-given(bird.name).willForward(to: Crow(name: "Ryan"))
-print(bird.name) // Prints "Ryan"
-
-// Additional targets take precedence
-given(bird.name).willForward(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Sterling"
-
-
Concrete stubs always have a higher priority than forwarding targets, regardless of the order
-they were added.
-
-
given(bird.name).willReturn("Ryan")
-given(bird.name).willForward(to: Crow(name: "Sterling"))
-print(bird.name) // Prints "Ryan"
-
-
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
-
-
given(bird.canChirp(volume: any())).willReturn(true) // Any volume
-given(bird.canChirp(volume: notNil())).willReturn(true) // Any non-nil volume
-given(bird.canChirp(volume: 10)).willReturn(true) // Volume = 10
-
-
-
Parameters
-
-
-
-
-
Name
-
Type
-
Description
-
-
-
-
-
value
-
ReturnType
-
A stubbed value to return.
-
-
-
-
-
Returns
-
The current stubbing manager which can be used to chain additional stubs.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.name).willReturn(lastSetValue(initial: ""))
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-
-
Implementation providers usually return multiple values, so when using chained stubbing it's
-necessary to specify a transition strategy that defines when to go to the next stub.
-
-
given(bird.name)
- .willReturn(lastSetValue(initial: ""), transition: .after(2))
- .willReturn("Sterling")
-
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
To return default values for unstubbed methods, use a ValueProvider with the initialized mock.
-Mockingbird provides preset value providers which are guaranteed to be backwards compatible,
-such as .standardProvider.
-
-
letbird = mock(Bird.self)
-bird.useDefaultValues(from: .standardProvider)
-print(bird.name) // Prints ""
-
-
You can create custom value providers by registering values for types.
Value providers can be composed by adding values from another provider. Values in the other
-provider have precedence and will overwrite existing values in this provider.
-
-
varvalueProvider = ValueProvider()
-valueProvider.add(.standardProvider)
-print(valueProvider.provideValue(for: String.self)) // Prints ""
-
Register a Providable type used to provide values for generic types.
-
-
-
-
Provide wildcard instances for generic types by conforming the base type to Providable and
-registering the type. Non-wildcard instances have precedence over wildcard instances.
-
-
extensionArray: Providable {
- publicstaticfunccreateInstance() -> Self? {
- returnArray()
- }
-}
-
-varvalueProvider = ValueProvider()
-valueProvider.registerType(Array<Any>.self)
-
-// All specializations of `Array` return an empty array
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints []
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
-// Register a non-wildcard instance of `Array<String>`
-valueProvider.register(["A", "B"], for: Array<String>.self)
-print(valueProvider.provideValue(for: Array<String>.self)) // Prints ["A", "B"]
-print(valueProvider.provideValue(for: Array<Data>.self)) // Prints []
-
publicfuncany<T: NSObjectProtocol>(_type: T.Type = T.self) -> T
-
-
-
Matches all Objective-C object argument values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the wildcard argument matcher any as a type safe placeholder for matching any argument
-value.
-
-
given(bird.canChirp(volume: any())).willReturn(true)
-print(bird.canChirp(volume: 10)) // Prints "true"
-verify(bird.canChirp(volume: any())).wasCalled()
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any dictionary containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match dictionaries that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, containingvalues: T.Element...) -> T
-
-
-
Matches any collection containing all of the values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(containing:) to match collections that contain all specified
-values.
publicfuncany<T: Collection>(_type: T.Type = T.self, countcountMatcher: CountMatcher) -> T
-
-
-
Matches any collection with a specific number of elements.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(count:) to match collections with a specific number of elements.
Matches any dictionary containing all of the keys.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(keys:) to match dictionaries that contain all specified keys.
publicfuncany<T: AnyObject>(_type: T.Type = T.self, ofobjects: T...) -> T
-
-
-
Matches argument values identical to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match objects identical to one or more of the specified
-values.
publicfuncany<T: Equatable>(_type: T.Type = T.self, ofobjects: T...) -> T
-
-
-
Matches argument values equal to any of the provided values.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(of:) to match Equatable argument values equal to one or more of
-the specified values.
-
-
given(bird.canChirp(volume: any(of: 1, 3)))
- .willReturn(true)
-
-given(bird.canChirp(volume: any(of: 2, 4)))
- .willReturn(false)
-
-print(bird.canChirp(volume: 1)) // Prints "true"
-print(bird.canChirp(volume: 2)) // Prints "false"
-print(bird.canChirp(volume: 3)) // Prints "true"
-print(bird.canChirp(volume: 4)) // Prints "false"
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
-
-
// Value type not explicitly conforming to `Equatable`
-structFruit {
- letsize: Int
-}
-
-protocolBird {
- funceat(_fruit: Fruit)
-}
-
-given(bird.eat(any(where: { $0.size < 100 })))
- .will { print($0.size) }
-
-letapple = Fruit(size: 42)
-bird.eat(apple) // Prints "42"
-
-letpear = Fruit(size: 9001)
-bird.eat(pear) // Error: Missing stubbed implementation
-
-
Methods overloaded by parameter type can be disambiguated by explicitly specifying the type.
Matches any Objective-C object argument values where the predicate returns true.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher any(where:) to match objects with custom equality logic. This is
-particularly useful for parameter types that do not conform to Equatable.
publicfuncaround<T: FloatingPoint>(_value: T, tolerance: T) -> T
-
-
-
Matches floating point arguments within some tolerance.
-
-
-
-
Mathematical operations on floating point numbers can cause loss of precision. Fuzzily match floating point arguments instead of using exact values to increase the robustness of tests.
The atLeast count matcher can be used to verify that the actual number of invocations received
-by a mock is greater than or equal to the expected number of invocations.
The atMost count matcher can be used to verify that the actual number of invocations received
-by a mock is less than or equal to the expected number of invocations.
The between count matcher can be used to verify that the actual number of invocations received
-by a mock is within an inclusive range of expected invocations.
-
-
// Given two invocations (n = 2)
-bird.fly()
-bird.fly()
-
-verify(bird.fly()).wasCalled(between(1...2)) // Passes
-verify(bird.fly()).wasCalled(between(3...4)) // Fails (3 ≮ n < 4)
-
-
You can combine count matchers with adverbial counts for improved readability.
Provide one or more implementations which will be returned sequentially for each invocation. The
-stub will be invalidated if the number of invocations is greater than the number of
-implementations provided.
Provide one or more values which will be returned sequentially for each invocation. The stub
-will be invalidated if the number of invocations is greater than the number of values provided.
Forward calls for a specific declaration to an object.
-
-
-
-
Objects are strongly referenced and receive proxed invocations until removed with clearStubs.
-Targets added afterwards have a higher precedence and only pass calls down the forwarding chain
-if unable handle the invocation, such as when the target is unrelated to the mocked type.
Objects must inherit from the mocked type to handle forwarded invocations, even if the
-declaration is identical. Adding an unrelated type as a forwarding target is a no-op.
Forward calls for a specific declaration to the superclass.
-
-
-
-
Use willForwardToSuper on class mock declarations to call the superclass implementation.
-Superclass forwarding persists until removed with clearStubs or shadowed by a forwarding
-target that was added afterwards.
An inOrder block is resolved greedily, such that each verification must happen from the oldest
-remaining unsatisfied invocations.
-
-
// Given these unsatisfied invocations
-bird.canFly
-bird.canFly
-bird.fly()
-
-// Greedy strategy _must_ start from the first `canFly`
-inOrder {
- verify(bird.canFly).wasCalled(twice)
- verify(bird.fly()).wasCalled()
-}
-
-// Non-greedy strategy can start from the second `canFly`
-inOrder {
- verify(bird.canFly).wasCalled()
- verify(bird.fly()).wasCalled()
-}
-
Provide one or more values which will be returned sequentially for each invocation. The sequence
-will loop from the beginning if the number of invocations is greater than the number of values
-provided.
-
-
given(bird.name)
- .willReturn(loopingSequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-sequence will loop from the beginning if the number of invocations is greater than the number of
-implementations provided.
-
-
given(bird.name).willReturn(loopingSequence(of: {
- returnBool.random() ? "Ryan" : "Meisters"
-}, {
- returnBool.random() ? "Sterling" : "Hackley"
-}))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Meisters"
-print(bird.name) // Prints "Hackley"
-
@available(*, unavailable, message: "No generated mock for this type which might be resolved by building the test target (⇧⌘U)")
-publicfuncmock<T>(_type: T.Type) -> T
-
-
-
Returns a mock of a given Swift type.
-
-
-
-
Initialized mocks can be passed in place of the original type. Protocol mocks do not require
-explicit initialization while class mocks should be created using initialize(…).
Generated mock types are suffixed with Mock and should not be coerced into their supertype.
-
-
letbird: BirdMock = mock(Bird.self) // The concrete type is `BirdMock`
-letinferredBird = mock(Bird.self) // Type inference also works
-letcoerced: Bird = mock(Bird.self) // Avoid upcasting mocks
-
publicfuncmock<T: NSObjectProtocol>(_type: T.Type) -> T
-
-
-
Returns a dynamic mock of a given Objective-C object type.
-
-
-
-
Initialized mocks can be passed in place of the original type. Dynamic mocks use the
-Objective-C runtime and do not require explicit initialization like Swift class mocks.
It's also possible to mock Swift types inheriting from NSObject or conforming to
-NSObjectProtocol. Members must be dynamically dispatched and available to the Objective-C
-runtime by specifying the objc attribute and dynamic modifier.
publicfuncnotEmpty<T: Collection>(_type: T.Type = T.self) -> T
-
-
-
Matches any collection with at least one element.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notEmpty to match collections with one or more elements.
publicfuncnotNil<T: NSObjectProtocol>(_type: T.Type = T.self) -> T
-
-
-
Matches any non-nil Objective-C object argument value.
-
-
-
-
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
Argument matching allows you to stub or verify specific invocations of parameterized methods.
-Use the argument matcher notNil to match non-nil argument values.
Provide one or more values which will be returned sequentially for each invocation. The last
-value will be used if the number of invocations is greater than the number of values provided.
-
-
given(bird.name)
- .willReturn(sequence(of: "Ryan", "Sterling"))
-
-print(bird.name) // Prints "Ryan"
-print(bird.name) // Prints "Sterling"
-print(bird.name) // Prints "Sterling"
-
Provide one or more implementations which will be returned sequentially for each invocation. The
-last implementation will be used if the number of invocations is greater than the number of
-implementations provided.
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
Match exact or wildcard argument values when verifying methods with parameters.
-
-
verify(bird.canChirp(volume: any())).wasCalled() // Called with any volume
-verify(bird.canChirp(volume: notNil())).wasCalled() // Called with any non-nil volume
-verify(bird.canChirp(volume: 10)).wasCalled() // Called with volume = 10
-
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
Match exact or wildcard argument values when stubbing methods with parameters. Stubs added
-later have a higher precedence, so add stubs with specific matchers last.
Stub a mocked method or property with an implementation provider.
-
-
-
-
There are several preset implementation providers such as lastSetValue, which can be used
-with property getters to automatically save and return values.
-
-
given(bird.name) ~> lastSetValue(initial: "")
-print(bird.name) // Prints ""
-bird.name = "Ryan"
-print(bird.name) // Prints "Ryan"
-