Files
swift-composable-architectu…/Tests/ComposableArchitectureTests/EffectFailureTests.swift
Stephen Celis 3e830b575a Swift Testing support (#3229)
* wip

* wip

* Update Testing.md

* wip

* wip

* wip

* wip

* wip:

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* wip

* disable library evolution

* bump

* wip

---------

Co-authored-by: Brandon Williams <mbrandonw@hey.com>
2024-07-22 17:52:04 -07:00

33 lines
872 B
Swift

#if DEBUG
import Combine
@_spi(Internals) import ComposableArchitecture
import XCTest
final class EffectFailureTests: BaseTCATestCase {
@MainActor
func testRunUnexpectedThrows() async {
guard #available(iOS 15, macOS 12, tvOS 15, watchOS 8, *) else { return }
var line: UInt!
XCTExpectFailure {
$0.compactDescription == """
failed - An "Effect.run" returned from "\(#fileID):\(line+1)" threw an unhandled error. …
EffectFailureTests.Unexpected()
All non-cancellation errors must be explicitly handled via the "catch" parameter on \
"Effect.run", or via a "do" block.
"""
}
line = #line
let effect = Effect<Void>.run { _ in
struct Unexpected: Error {}
throw Unexpected()
}
for await _ in effect.actions {}
}
}
#endif