Swift Package Manager,如何处理固定装置?

时间:2019-06-21 23:52:02

标签: swift fixtures swift-package-manager

我正在将DVR集成到我正在编写的HTTP请求繁重库的测试中。我正在使用Swift Package Manager(在使用Xcode 11 Beta的macOS 10.15上)来管理我的依赖关系,而且我不确定如何将DVR生成的设备包含到测试目标中。如何将我的装置从DVR添加到测试目标?

我尝试使用默认的Session配置,并尝试使用Session(outputDirectory: "Fixtures", cassetteName: "example", testBundle: .main, backingSession: .shared)

将灯具存储在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"]
        )
    ]
)

运行测试时,出现错误[DVR] Persisted cassette at Fixtures/example.json. Please add this file to your test target

我不确定如何将此目录添加到我的测试目标中。

1 个答案:

答案 0 :(得分:1)

从Swift 5.1开始,这样的外观可能是不可能的。快捷票:SR-2866