From 2ec3883955686ed9e8bcbfa900fcb46e73ad1ebe Mon Sep 17 00:00:00 2001 From: 0xLeif Date: Tue, 7 Jun 2022 17:13:13 -0600 Subject: [PATCH 1/2] Use XCTFail from XCTestDynamicOverlay as default handler --- Sources/CacheStore/Stores/Store.swift | 2 +- Sources/CacheStore/Stores/TestStore.swift | 15 ++------------- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/Sources/CacheStore/Stores/Store.swift b/Sources/CacheStore/Stores/Store.swift index 7e0f57c..3454cb6 100644 --- a/Sources/CacheStore/Stores/Store.swift +++ b/Sources/CacheStore/Stores/Store.swift @@ -222,7 +222,7 @@ public class Store: ObservableObject, ActionH // MARK: - Void Dependency -public extension Store { +public extension Store where Dependency == Void { /// Creates a `ScopedStore` func scope( keyTransformation: c.BiDirectionalTransformation, diff --git a/Sources/CacheStore/Stores/TestStore.swift b/Sources/CacheStore/Stores/TestStore.swift index 625f626..fab9dd0 100644 --- a/Sources/CacheStore/Stores/TestStore.swift +++ b/Sources/CacheStore/Stores/TestStore.swift @@ -1,13 +1,14 @@ #if DEBUG import CustomDump import Foundation +import XCTestDynamicOverlay /// Facade typealias for XCTFail without importing XCTest public typealias FailureHandler = (_ message: String, _ file: StaticString, _ line: UInt) -> Void /// Static object to provide the `FailureHandler` to any `TestStore` public enum TestStoreFailure { - public static var handler: FailureHandler! + public static var handler: FailureHandler = XCTestDynamicOverlay.XCTFail } /// Testable `Store` where you can send and receive actions while expecting the changes @@ -42,18 +43,6 @@ public class TestStore { file: StaticString = #filePath, line: UInt = #line ) { - assert( - TestStoreFailure.handler != nil, - """ - Set `TestStoreFailure.handler` - - override func setUp() { - TestStoreFailure.handler = XCTFail - } - - """ - ) - store = Store(initialValues: initialValues, actionHandler: actionHandler, dependency: dependency).debug effects = [] initFile = file From 45b2b98ac797affeef773f0c8f719f77e32609be Mon Sep 17 00:00:00 2001 From: 0xLeif Date: Tue, 7 Jun 2022 17:13:54 -0600 Subject: [PATCH 2/2] update readme --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index 2e7cb1a..3604e5c 100644 --- a/README.md +++ b/README.md @@ -147,10 +147,6 @@ import XCTest @testable import CacheStoreDemo class CacheStoreDemoTests: XCTestCase { - override func setUp() { - TestStoreFailure.handler = XCTFail - } - func testExample_success() throws { let store = TestStore( initialValues: [