Skip to content

Commit 2ec3883

Browse files
committed
Use XCTFail from XCTestDynamicOverlay as default handler
1 parent ea2f22b commit 2ec3883

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

Sources/CacheStore/Stores/Store.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public class Store<Key: Hashable, Action, Dependency>: ObservableObject, ActionH
222222

223223
// MARK: - Void Dependency
224224

225-
public extension Store {
225+
public extension Store where Dependency == Void {
226226
/// Creates a `ScopedStore`
227227
func scope<ScopedKey: Hashable, ScopedAction>(
228228
keyTransformation: c.BiDirectionalTransformation<Key?, ScopedKey?>,

Sources/CacheStore/Stores/TestStore.swift

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#if DEBUG
22
import CustomDump
33
import Foundation
4+
import XCTestDynamicOverlay
45

56
/// Facade typealias for XCTFail without importing XCTest
67
public typealias FailureHandler = (_ message: String, _ file: StaticString, _ line: UInt) -> Void
78

89
/// Static object to provide the `FailureHandler` to any `TestStore`
910
public enum TestStoreFailure {
10-
public static var handler: FailureHandler!
11+
public static var handler: FailureHandler = XCTestDynamicOverlay.XCTFail
1112
}
1213

1314
/// Testable `Store` where you can send and receive actions while expecting the changes
@@ -42,18 +43,6 @@ public class TestStore<Key: Hashable, Action, Dependency> {
4243
file: StaticString = #filePath,
4344
line: UInt = #line
4445
) {
45-
assert(
46-
TestStoreFailure.handler != nil,
47-
"""
48-
Set `TestStoreFailure.handler`
49-
50-
override func setUp() {
51-
TestStoreFailure.handler = XCTFail
52-
}
53-
54-
"""
55-
)
56-
5746
store = Store(initialValues: initialValues, actionHandler: actionHandler, dependency: dependency).debug
5847
effects = []
5948
initFile = file

0 commit comments

Comments
 (0)