swift - Swift Package Manager,如何处理夹具?
问题描述
我正在寻找将DVR集成到我正在编写的 HTTP 请求繁重的库的测试中。我正在使用 Swift 包管理器(在 macOS 10.15 上使用 Xcode 11 Beta)来管理我的依赖项,但我不确定如何将 DVR 生成的固定装置包含到我的测试目标中。如何将我的设备从 DVR 添加到我的测试目标?
我尝试使用默认的 Session 配置以及尝试使用Session(outputDirectory: "Fixtures", cassetteName: "example", testBundle: .main, backingSession: .shared)
我的包文件如下:
// 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"]
)
]
)
运行测试时,出现错误[DVR] Persisted cassette at Fixtures/example.json. Please add this file to your test target
我不确定如何将此目录添加到我的测试目标。
解决方案
从 Swift 5.1 开始,这似乎是不可能的。斯威夫特票:SR-2866
推荐阅读
- asp.net-mvc - 锚标记如何在 MVC 中触发 HTML 动作?
- c# - Azure blob 文件名中的模式搜索
- c++ - 使用 MATLAB Coder 生成的 C++ 代码:编译错误“未定义对 `rgb2gray_tbb_real64' 的引用”
- c# - 如何在 [InitializeOnLoad] 脚本类型中更改层次结构上的 GameObjects 位置?
- html - 如何从中间而不是左轴居中对齐按钮
- python - pip install paho-mqtt 回溯(最后一次调用)
- or-tools - 谷歌 OR 工具 CP 求解器
- javascript - 如何从客户端发送 JavaScript 对象以及如何在 Spring Boot 后端接收和解析它们?
- mysql - 从 MariaDB Galera 集群捕获更改数据
- javascript - 日期选择器无法填充日期字段