Skip to content

Commit cc535c3

Browse files
authored
XCTUnimplemented -> unimplemented (#1530)
1 parent 847b470 commit cc535c3

File tree

13 files changed

+40
-47
lines changed

13 files changed

+40
-47
lines changed

ComposableArchitecture.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-LongLiving.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ private enum ScreenshotsKey: DependencyKey {
6161
.map { _ in }
6262
)
6363
}
64-
static let testValue: @Sendable () async -> AsyncStream<Void> = XCTUnimplemented(
64+
static let testValue: @Sendable () async -> AsyncStream<Void> = unimplemented(
6565
#"@Dependency(\.screenshots)"#, placeholder: .finished
6666
)
6767
}

Examples/CaseStudies/SwiftUICaseStudies/02-Effects-WebSocket.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ extension WebSocketClient: DependencyKey {
326326
}
327327

328328
static let testValue = Self(
329-
open: XCTUnimplemented("\(Self.self).open", placeholder: AsyncStream.never),
330-
receive: XCTUnimplemented("\(Self.self).receive"),
331-
send: XCTUnimplemented("\(Self.self).send"),
332-
sendPing: XCTUnimplemented("\(Self.self).sendPing")
329+
open: unimplemented("\(Self.self).open", placeholder: AsyncStream.never),
330+
receive: unimplemented("\(Self.self).receive"),
331+
send: unimplemented("\(Self.self).send"),
332+
sendPing: unimplemented("\(Self.self).sendPing")
333333
)
334334
}
335335

Examples/CaseStudies/SwiftUICaseStudies/04-HigherOrderReducers-ResuableOfflineDownloads/DownloadClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,6 @@ extension DownloadClient: DependencyKey {
4747
)
4848

4949
static let testValue = Self(
50-
download: XCTUnimplemented("\(Self.self).download")
50+
download: unimplemented("\(Self.self).download")
5151
)
5252
}

Examples/CaseStudies/SwiftUICaseStudies/FactClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ extension FactClient: DependencyKey {
2929
/// This is the "unimplemented" fact dependency that is useful to plug into tests that you want
3030
/// to prove do not need the dependency.
3131
static let testValue = Self(
32-
fetch: XCTUnimplemented("\(Self.self).fetch")
32+
fetch: unimplemented("\(Self.self).fetch")
3333
)
3434
}

Examples/Search/Search/WeatherClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ extension WeatherClient: TestDependencyKey {
5050
)
5151

5252
static let testValue = Self(
53-
forecast: XCTUnimplemented("\(Self.self).forecast"),
54-
search: XCTUnimplemented("\(Self.self).search")
53+
forecast: unimplemented("\(Self.self).forecast"),
54+
search: unimplemented("\(Self.self).search")
5555
)
5656
}
5757

Examples/SpeechRecognition/SpeechRecognition/SpeechClient/Client.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ extension SpeechClient: TestDependencyKey {
6767
}
6868

6969
static let testValue = Self(
70-
finishTask: XCTUnimplemented("\(Self.self).finishTask"),
71-
requestAuthorization: XCTUnimplemented(
70+
finishTask: unimplemented("\(Self.self).finishTask"),
71+
requestAuthorization: unimplemented(
7272
"\(Self.self).requestAuthorization", placeholder: .notDetermined
7373
),
74-
startTask: XCTUnimplemented("\(Self.self).recognitionTask", placeholder: .never)
74+
startTask: unimplemented("\(Self.self).recognitionTask", placeholder: .never)
7575
)
7676
}
7777

Examples/TicTacToe/tic-tac-toe/Sources/AuthenticationClient/AuthenticationClient.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public struct AuthenticationClient: Sendable {
7373

7474
extension AuthenticationClient: TestDependencyKey {
7575
public static var testValue = Self(
76-
login: XCTUnimplemented("\(Self.self).login"),
77-
twoFactor: XCTUnimplemented("\(Self.self).twoFactor")
76+
login: unimplemented("\(Self.self).login"),
77+
twoFactor: unimplemented("\(Self.self).twoFactor")
7878
)
7979
}
8080

Examples/VoiceMemos/VoiceMemos/AudioPlayerClient/AudioPlayerClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ extension AudioPlayerClient: TestDependencyKey {
1515
)
1616

1717
static let testValue = Self(
18-
play: XCTUnimplemented("\(Self.self).play")
18+
play: unimplemented("\(Self.self).play")
1919
)
2020
}
2121

Examples/VoiceMemos/VoiceMemos/AudioRecorderClient/AudioRecorderClient.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ extension AudioRecorderClient: TestDependencyKey {
3434
}
3535

3636
static let testValue = Self(
37-
currentTime: XCTUnimplemented("\(Self.self).currentTime", placeholder: nil),
38-
requestRecordPermission: XCTUnimplemented(
37+
currentTime: unimplemented("\(Self.self).currentTime", placeholder: nil),
38+
requestRecordPermission: unimplemented(
3939
"\(Self.self).requestRecordPermission", placeholder: false
4040
),
41-
startRecording: XCTUnimplemented("\(Self.self).startRecording", placeholder: false),
42-
stopRecording: XCTUnimplemented("\(Self.self).stopRecording")
41+
startRecording: unimplemented("\(Self.self).startRecording", placeholder: false),
42+
stopRecording: unimplemented("\(Self.self).stopRecording")
4343
)
4444
}
4545

Examples/VoiceMemos/VoiceMemos/Dependencies.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extension DependencyValues {
1616
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
1717
}
1818
}
19-
static let testValue: @Sendable () async -> Void = XCTUnimplemented(
19+
static let testValue: @Sendable () async -> Void = unimplemented(
2020
#"@Dependency(\.openSettings)"#
2121
)
2222
}
@@ -28,7 +28,7 @@ extension DependencyValues {
2828

2929
private enum TemporaryDirectoryKey: DependencyKey {
3030
static let liveValue: @Sendable () -> URL = { URL(fileURLWithPath: NSTemporaryDirectory()) }
31-
static let testValue: @Sendable () -> URL = XCTUnimplemented(
31+
static let testValue: @Sendable () -> URL = unimplemented(
3232
#"@Dependency(\.temporaryDirectory)"#
3333
)
3434
}

Sources/ComposableArchitecture/Documentation.docc/Articles/DependencyManagement.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -315,27 +315,20 @@ Unfortunately, `XCTFail` cannot be used in non-test targets, and so this instanc
315315
in the same file where your dependency is registered. To work around this you can use our
316316
[XCTestDynamicOverlay][xctest-dynamic-overlay-gh] library that dynamically invokes `XCTFail` and
317317
it is automatically accessible when using the Composable Architecture. It also comes with some
318-
helpers to ease the construction of these unimplemented values:
318+
helpers to ease the construction of these unimplemented values, which we can use when defining the
319+
`testValue` of your dependency:
319320

320321
```swift
321322
import XCTestDynamicOverlay
322323

323324
extension APIClient {
324-
static let unimplemented = Self(
325-
fetchUser: XCTUnimplemented("APIClient.fetchUser")
326-
fetchUsers: XCTUnimplemented("APIClient.fetchUsers")
325+
static let testValue = Self(
326+
fetchUser: unimplemented("APIClient.fetchUser")
327+
fetchUsers: unimplemented("APIClient.fetchUsers")
327328
)
328329
}
329330
```
330331

331-
This is now the value that is most appropriate to use as the `testValue` of your dependency:
332-
333-
```swift
334-
extension APIClient: TestDependencyKey {
335-
static let testValue = APIClient.unimplemented
336-
}
337-
```
338-
339332
The other requirement of `TestDependencyKey` is `previewValue`, and if this value is implemented
340333
it will be used whenever your feature is run in an Xcode preview. Previews are similar to tests in
341334
that you usually do not want to interact with the outside world, such as making network requests.

Sources/ComposableArchitecture/Effect.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -490,17 +490,17 @@ extension EffectPublisher {
490490
///
491491
/// > Important: This Combine-based interface has been soft-deprecated in favor of Swift
492492
/// > concurrency. Prefer using async functions and `AsyncStream`s directly in your dependencies,
493-
/// > and using `XCTUnimplemented` from the [XCTest Dynamic Overlay](gh-xctest-dynamic-overlay)
493+
/// > and using `unimplemented` from the [XCTest Dynamic Overlay](gh-xctest-dynamic-overlay)
494494
/// > library to stub in a function that fails when invoked:
495495
/// >
496496
/// > ```swift
497497
/// > struct NumberFactClient {
498498
/// > var fetch: (Int) async throws -> String
499499
/// > }
500500
/// >
501-
/// > extension NumberFactClient {
502-
/// > static let unimplemented = Self(
503-
/// > fetch: XCTUnimplemented(
501+
/// > extension NumberFactClient: TestDependencyKey {
502+
/// > static let testValue = Self(
503+
/// > fetch: unimplemented(
504504
/// > "\(Self.self).fetch",
505505
/// > placeholder: "Not an interesting number."
506506
/// > )
@@ -590,16 +590,16 @@ extension EffectPublisher {
590590
/// messages.
591591
/// - Returns: An effect that causes a test to fail if it runs.
592592
@available(
593-
iOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead."
593+
iOS, deprecated: 9999.0, message: "Call 'unimplemented' from your dependencies, instead."
594594
)
595595
@available(
596-
macOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead."
596+
macOS, deprecated: 9999.0, message: "Call 'unimplemented' from your dependencies, instead."
597597
)
598598
@available(
599-
tvOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead."
599+
tvOS, deprecated: 9999.0, message: "Call 'unimplemented' from your dependencies, instead."
600600
)
601601
@available(
602-
watchOS, deprecated: 9999.0, message: "Call 'XCTUnimplemented' from your dependencies, instead."
602+
watchOS, deprecated: 9999.0, message: "Call 'unimplemented' from your dependencies, instead."
603603
)
604604
public static func unimplemented(_ prefix: String) -> Self {
605605
.fireAndForget {

0 commit comments

Comments
 (0)