File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Dependencies/Documentation.docc/Articles Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -229,5 +229,25 @@ dependency from the implementation (see
229
229
< doc:LivePreviewTest#Separating-interface-and-implementation > for more information). But now there
230
230
is no need to maintain that code as it is automatically provided for you by the macro.
231
231
232
+ > Warning: Due to a [ bug in the Swift compiler] ( https://github.com/apple/swift/issues/71070 ) ,
233
+ > endpoints that are not throwing will not emit a test failure when invoked. This applies to
234
+ > dependencies with endpoints like this:
235
+ >
236
+ > ``` swift
237
+ > @DependencyClient
238
+ > struct NumberFetcher {
239
+ > var get: () async -> Int = { 42 }
240
+ > }
241
+ > ```
242
+ >
243
+ > The workaround is to invoke `XCTFail` directly in the closure:
244
+ >
245
+ > ```swift
246
+ > @DependencyClient
247
+ > struct NumberFetcher {
248
+ > var get: () async -> Int = { XCTFail (" \( Self .self ) .get" ); return 42 }
249
+ > }
250
+ > ```
251
+
232
252
[designing- deps]: https: // www.pointfree.co/collections/dependencies
233
253
[xctest- dynamic - overlay- gh]: http: // github.com/pointfreeco/xctest-dynamic-overlay
Original file line number Diff line number Diff line change 111
111
/// and does not need to signify a real value. For example, if the endpoint returns a boolean, you
112
112
/// can return `false`, or if it returns an array, you can return `[]`.`
113
113
///
114
+ /// > Warning: Due to a [bug in the Swift compiler](https://github.com/apple/swift/issues/71070),
115
+ /// > endpoints that are not throwing will not emit a test failure when invoked. This applies to
116
+ /// > dependencies with endpoints like this:
117
+ /// >
118
+ /// > ```swift
119
+ /// > @DependencyClient
120
+ /// > struct NumberFetcher {
121
+ /// > var get: () async -> Int = { 42 }
122
+ /// > }
123
+ /// > ```
124
+ /// >
125
+ /// > The workaround is to invoke `XCTFail` directly in the closure:
126
+ /// >
127
+ /// > ```swift
128
+ /// > @DependencyClient
129
+ /// > struct NumberFetcher {
130
+ /// > var get: () async -> Int = { XCTFail("\(Self.self).get"); return 42 }
131
+ /// > }
132
+ /// > ```
133
+ ///
114
134
/// [designing-dependencies]: https://swiftpackageindex.com/pointfreeco/swift-dependencies/main/documentation/dependencies/designingdependencies
115
135
/// [separating-interface-implementation]: https://swiftpackageindex.com/pointfreeco/swift-dependencies/main/documentation/dependencies/livepreviewtest#Separating-interface-and-implementation
116
136
@attached ( member, names: named ( init) )
You can’t perform that action at this time.
0 commit comments