Skip to content

Commit bc2d28e

Browse files
authored
Merge pull request #14 from 0xOpenBytes/xctfail-from-overlay
Use XCTFail from XCTestDynamicOverlay as default handler
2 parents ea2f22b + 45b2b98 commit bc2d28e

File tree

3 files changed

+3
-18
lines changed

3 files changed

+3
-18
lines changed

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,6 @@ import XCTest
147147
@testable import CacheStoreDemo
148148

149149
class CacheStoreDemoTests: XCTestCase {
150-
override func setUp() {
151-
TestStoreFailure.handler = XCTFail
152-
}
153-
154150
func testExample_success() throws {
155151
let store = TestStore(
156152
initialValues: [

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)