I'm using SPM to achieve modular architecture in my iOS Xcode project. That's my package.swift
:
let targets: [Target] = [
.target(name: "Home", dependencies: ["Texture", ...]),
.testTarget(name: "HomeTests", dependencies: ["Home", ...]),
.target(name: "Inbox", dependencies: []),
.testTarget(name: "Inbox”Tests", dependencies: ["Inbox", ...]),
.target(name: “Settings”, dependencies: []),
.testTarget(name: "SettingsTests", dependencies: ["Settings", ...]),
]
let package = Package(
name: "MyPackage",
platforms: [.iOS(.v14), .macOS(.v10_15)],
products: targets.filter { !$0.isTest }.map { .library(name: $0.name, targets: [$0.name]) },
dependencies: [...],
targets: targets)
)
As you can see I have test target for each module. TestTargets contain unit tests. How can I run all the test targets together? For now I can only run each test target independently and it takes too much time to test the whole app.
You can use a test plan and edit the current scheme and add the tests you want to run in the test phase:
3.- Add the test targets into the test plan
4.- Optionally you can gather coverage in the test plan by going into the "Configurations" tab.