I'm trying to break down a project into small local packages with their respective tests. I couldn't find any examples on how to use Cuckoo in such a scenario. Should I bundle a Cuckoofile for each local package? Appreciate your suggestions.
I'm trying to break down a project into small local packages with their respective tests. I couldn't find any examples on how to use Cuckoo in such a scenario. Should I bundle a Cuckoofile for each local package? Appreciate your suggestions.
Share Improve this question edited 21 hours ago David Pasztor 54.7k9 gold badges96 silver badges127 bronze badges asked yesterday James SelvakumarJames Selvakumar 2,8392 gold badges26 silver badges29 bronze badges1 Answer
Reset to default 0To integrate Cuckoo into a Local Swift Package, I had to define a Cuckoofile.toml in the root of the local package like this:
[modules.MyPackage]
output = "Tests/MyPackageTests/GeneratedMocks.swift"
imports = ["MyPackage"]
sources = [
"Sources/MyPackage/*.swift",
]
I also had to define the Cuckoo plugin in MyPackage's Package.swift.
import PackageDescription
let package = Package(
name: "MyPackage",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "MyPackage",
targets: ["MyPackage"]),
],
dependencies: [
.package(url: "https://github/Quick/Quick.git", from: "7.0.0"),
.package(url: "https://github/Quick/Nimble.git", from: "12.0.0"),
.package(url: "https://github/Brightify/Cuckoo.git", from: "2.0.0")
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "MyPackage"),
.testTarget(
name: "MyPackageTests",
dependencies: ["MyPackage", "Quick", "Nimble", "Cuckoo"],
plugins: [
.plugin(name: "CuckooPluginSingleFile", package: "Cuckoo")
]
),
]
)
Then when I ran the tests, my build failed. As I observed the build log, I saw a link to enable this plugin. I clicked it to enable and then the mocks were generated.