diff --git a/Tests/ComposableArchitectureTests/StoreTests.swift b/Tests/ComposableArchitectureTests/StoreTests.swift index 602f1a2c2c4f..7ef9bccebecd 100644 --- a/Tests/ComposableArchitectureTests/StoreTests.swift +++ b/Tests/ComposableArchitectureTests/StoreTests.swift @@ -1176,50 +1176,52 @@ final class StoreTests: BaseTCATestCase { } } -@Suite -struct ModernStoreTests { - @Reducer - fileprivate struct TaskTreeFeature { - let clock: TestClock - @ObservableState - struct State { var count = 0 } - enum Action { case tap, response1, response2 } - var body: some ReducerOf { - Reduce { state, action in - switch action { - case .tap: - return Effect.run { send in - await send(.response1) - } - case .response1: - state.count = 42 - return Effect.run { send in - try await clock.sleep(for: .seconds(1)) - await send(.response2) +#if canImport(Testing) + @Suite + struct ModernStoreTests { + @Reducer + fileprivate struct TaskTreeFeature { + let clock: TestClock + @ObservableState + struct State { var count = 0 } + enum Action { case tap, response1, response2 } + var body: some ReducerOf { + Reduce { state, action in + switch action { + case .tap: + return Effect.run { send in + await send(.response1) + } + case .response1: + state.count = 42 + return Effect.run { send in + try await clock.sleep(for: .seconds(1)) + await send(.response2) + } + case .response2: + state.count = 1729 + return .none } - case .response2: - state.count = 1729 - return .none } } } - } - @MainActor - @Test - func cancellation() async throws { - let clock = TestClock() - let store = Store(initialState: TaskTreeFeature.State()) { TaskTreeFeature(clock: clock) } - let task = store.send(.tap) - try await Task.sleep(for: .seconds(0.1)) - #expect(store.count == 42) - task.cancel() - await clock.run() - withKnownIssue("Cancelling the root effect should not cancel the child effects.") { - #expect(store.count == 1729) + @MainActor + @Test + func cancellation() async throws { + let clock = TestClock() + let store = Store(initialState: TaskTreeFeature.State()) { TaskTreeFeature(clock: clock) } + let task = store.send(.tap) + try await Task.sleep(for: .seconds(0.1)) + #expect(store.count == 42) + task.cancel() + await clock.run() + withKnownIssue("Cancelling the root effect should not cancel the child effects.") { + #expect(store.count == 1729) + } } } -} +#endif private struct Count: TestDependencyKey { var value: Int