CombineTest
为 Apple Combine 提供一组阻止操作符,以简化单元测试。API 已完全复制自 RxBlocking
请勿在生产应用中使用这些操作符。这些操作符仅用于测试目的。
extension BlockingPublisher {
func toArray() throws -> [Output]
}
extension BlockingPublisher {
func first() throws -> Output?
}
extension BlockingPublisher {
func last() throws -> Output?
}
extension BlockingPublisher {
func single(_ predicate: @escaping (Output) throws -> Bool) throws -> Output?
}
extension BlockingPublisher {
func materialize() -> MaterializedSequenceResult<Output>
}
安装
CocoaPods
在你的 Podfile 中
pod 'CombineTest'
Swift Package Manager
创建一个 Package.swift
文件。
// swift-tools-version:5.0
import PackageDescription
let package = Package(
name: "CombineTestProject",
dependencies: [
.package(url: "https://github.com/RxSwiftCommunity/CombineTest.git", from: "1.0.0")
],
targets: [
.target(name: "CombineTestProject", dependencies: [CombineTest])
]
)