我希望整合 DVR进入我正在编写的 HTTP 请求密集型库的测试。我正在使用 Swift Package Manager(在 macOS 10.15 上使用 Xcode 11 Beta)来管理我的依赖项,我不确定如何将 DVR 生成的装置包含到我的测试目标中。如何将我的灯具从 DVR 添加到我的测试目标?
我已经尝试使用默认的 Session 配置,并尝试使用 Session(outputDirectory: "Fixtures", cassetteName: "example", testBundle: .main, backingSession: 将灯具存储在 Fixtures 目录中。共享)
我的打包文件如下:
// swift-tools-version:5.1
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "Example",
products: [
// Products define the executables and libraries produced by a package, and make them visible to other packages.
.library(
name: "Example",
targets: ["Example"]),
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/venmo/DVR.git", from: "2.0.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages which this package depends on.
.target(
name: "Example",
dependencies: []
),
.testTarget(
name: "ExampleTests",
dependencies: ["Example", "DVR"]
)
]
)
运行测试时,我在 Fixtures/example.json 收到错误 [DVR] Persisted cassette。请将此文件添加到您的测试目标
我不确定如何将此目录添加到我的测试目标。
最佳答案
从 Swift 5.1 开始,这似乎是不可能的。 swift 票:SR-2866
关于Swift 包管理器,如何处理固定装置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56711551/