Skip to content

Commit f298e80

Browse files
mbrandonwmluisbrown
authored andcommitted
Soft deprecate Effect.unimplemented. (#1265)
* Soft deprecate Effect.unimplemented. * move deprecation back to effect file * wip * wip (cherry picked from commit c04272e63f198609400822970c4d7ae57a654970)
1 parent 44dc081 commit f298e80

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

Sources/ComposableArchitecture/Documentation.docc/Extensions/EffectDeprecations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ Avoid using deprecated APIs in your app. Select a method to see the replacement
2424
### Testing
2525

2626
- ``Effect/failing(_:)``
27+
- ``Effect/unimplemented(_:)``
2728

2829
### Combine Integration
2930

Sources/ComposableArchitecture/Effect.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,26 @@ extension Effect {
388388
extension Effect {
389389
/// An effect that causes a test to fail if it runs.
390390
///
391+
/// > Important: This Combine-based interface has been soft-deprecated in favor of Swift
392+
/// > concurrency. Prefer using async functions and `AsyncStream`s directly in your dependencies,
393+
/// > and using `XCTUnimplemented` from the [XCTest Dynamic Overlay](gh-xctest-dynamic-overlay)
394+
/// > library to stub in a function that fails when invoked:
395+
/// >
396+
/// > ```swift
397+
/// > struct NumberFactClient {
398+
/// > var fetch: (Int) async throws -> String
399+
/// > }
400+
/// >
401+
/// > extension NumberFactClient {
402+
/// > static let unimplemented = Self(
403+
/// > fetch: XCTUnimplemented(
404+
/// > "\(Self.self).fetch",
405+
/// > placeholder: "Not an interesting number."
406+
/// > )
407+
/// > }
408+
/// > }
409+
/// > ```
410+
///
391411
/// This effect can provide an additional layer of certainty that a tested code path does not
392412
/// execute a particular effect.
393413
///
@@ -464,9 +484,15 @@ extension Effect {
464484
/// made the test easier to understand at the same time. We can see, without consulting the
465485
/// reducer itself, that this particular action should not access this effect.
466486
///
487+
/// [gh-xctest-dynamic-overlay]: http://github.com/pointfreeco/xctest-dynamic-overlay
488+
///
467489
/// - Parameter prefix: A string that identifies this scheduler and will prefix all failure
468490
/// messages.
469491
/// - Returns: An effect that causes a test to fail if it runs.
492+
@available(iOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead.")
493+
@available(macOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead.")
494+
@available(tvOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead.")
495+
@available(watchOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead.")
470496
public static func unimplemented(_ prefix: String) -> Self {
471497
.fireAndForget {
472498
XCTFail("\(prefix.isEmpty ? "" : "\(prefix) - ")An unimplemented effect ran.")

0 commit comments

Comments
 (0)