You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Oct 2, 2025. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+82-9Lines changed: 82 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,14 +1,17 @@
1
1
# Dobby
2
2
3
-
Dobby provides a few helpers for mocking and stubbing using expectations.
3
+
Dobby provides a few helpers for mocking and stubbing.
4
4
5
-
## Expectations
5
+
## Matchers
6
6
7
-
Expectations can be matched with values, serving as the fundamental building block for mocking and stubbing. There are many functions that help creating expectations for (equatable) types, including tuples, arrays, and dictionaries with equatable elements:
7
+
Matchers can be matched with values, serving as the fundamental building block for mocking and stubbing. There are many functions that help creating matchers for (equatable) types, including optionals, tuples, arrays, and dictionaries with equatable elements:
Mocks can be used to verify that all set up expectations are matched with the recorded interactions. Verification is performed in order and all expectations must match an interaction and vice versa:
35
+
Mocks can be used to verify that all set up expectations have been fulfilled.
36
+
37
+
### Strict mocks
38
+
39
+
By default, mocks are strict and the order of expectations matters, meaning all interactions must be expected and occur in the order they were expected:
Stubs, when invoked, return a value based on their set up behavior, or, if an interaction is unexpected, return `nil`. Behavior is matched in order, i.e., the function or return value associated with the first expectation that matches an interaction is invoked/returned:
115
+
Stubs, when invoked, return a value based on their set up behavior, or, if an interaction is unexpected, return `nil`. Behavior is matched in order, i.e., the function or return value associated with the first matcher that matches an interaction is invoked/returned:
43
116
44
117
```swift
45
118
let stub = Stub<(Int, Int), Int>()
@@ -75,14 +148,14 @@ class MyClassMock: MyClass {
75
148
let myMethodMock = Mock<(String, String)>()
76
149
let myMethodStub = Stub<(String, String), String>()
The test subclass allows you to verify that all your set up expectations are matched with the recorded interactions and enables you to change its behavior on-the-fly:
158
+
The test subclass allows you to verify that all your set up expectations are fulfilled and enables you to change its behavior on-the-fly:
0 commit comments