Swift 包管理器,如何处理固定装置?

标签 swift fixtures swift-package-manager

我希望整合 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/

相关文章:

django - 测试期间未加载 fixture

symfony - 使用 security.encoder_factory 加速 symfony2 fixtures 在测试中的加载

python - 如何定义一个给定测试子目录中的所有测试使用的 pytest 固定装置?

ios - 将 CocoaPods 与 Swift 包混合使用

swift - 如何通过命令行为 iOS 构建 Swift 包?

ios - 如何识别从相机胶卷中选择的图像?

ios - NSURLSession 返回元组的问题

来自命令行的 Swift 包管理器 "Undefined symbols for architecture x86_64"

协议(protocol)中的 Swift 协议(protocol)属性 - 候选人具有不匹配的类型

ios - 如何在 swift 2 中获取 json 数据时启动和停止事件指示器?