diff --git a/Tests/ComposableArchitectureTests/EffectTests.swift b/Tests/ComposableArchitectureTests/EffectTests.swift index 6e1c3cce3e39..94f28cd92bc5 100644 --- a/Tests/ComposableArchitectureTests/EffectTests.swift +++ b/Tests/ComposableArchitectureTests/EffectTests.swift @@ -47,27 +47,29 @@ final class EffectTests: BaseTCATestCase { } func testConcatenateOneEffect() async { - let values = LockIsolated<[Int]>([]) - - let effect = Effect.concatenate( - .publisher { Just(1).delay(for: 1, scheduler: self.mainQueue) } - ) - - let task = Task { - for await n in effect.actions { - values.withValue { $0.append(n) } + await withMainSerialExecutor { + let values = LockIsolated<[Int]>([]) + + let effect = Effect.concatenate( + .publisher { Just(1).delay(for: 1, scheduler: self.mainQueue) } + ) + + let task = Task { + for await n in effect.actions { + values.withValue { $0.append(n) } + } } + + XCTAssertEqual(values.value, []) + + await self.mainQueue.advance(by: 1) + XCTAssertEqual(values.value, [1]) + + await self.mainQueue.run() + XCTAssertEqual(values.value, [1]) + + await task.value } - - XCTAssertEqual(values.value, []) - - await self.mainQueue.advance(by: 1) - XCTAssertEqual(values.value, [1]) - - await self.mainQueue.run() - XCTAssertEqual(values.value, [1]) - - await task.value } func testMerge() async {