CachiKit is a swift library to parse Xcode's 11 .xcresult files. It's the core librart used by Cachi a tool that parses and visualizes tests results in a web interface.
Add CachiKit as a dependency to your project:
dependencies: [
.package(url: "https://github.com/Subito-it/CachiKit", .branch("master"))
]
The library API is very simple and exposes a set of methods to extract parts of the result structure.
To get the root element of the xcresult
import CachiKit
let url = URL(fileURLWithPath: "path to the .xcresult")
let cachi = CachiKit(url: url)
let invocationRecord = try? cachi.actionsInvocationRecord()
From the action invocation record you can get the id to get the actions invocation metadata
import CachiKit
let url = URL(fileURLWithPath: "path to the .xcresult")
let cachi = CachiKit(url: url)
let invocationRecord = try? cachi.actionsInvocationRecord()
guard let metadataIdentifier = invocationRecord.metadataRef?.id else {
return
}
let metaData = try? cachi.actionsInvocationMetadata(identifier: metadataIdentifier)
import CachiKit
let url = URL(fileURLWithPath: "path to the .xcresult")
let cachi = CachiKit(url: url)
let invocationRecord = try? cachi.actionsInvocationRecord()
for action in invocationRecord.actions {
guard let testRef = action.actionResult.testsRef else { continue }
let testPlanSummaries = (try? cachi.actionTestPlanRunSummaries(identifier: testRef.id))?.summaries
}
You will need the test summary identifier which can be extracted from the TestPlanRunSummaries testableSummaries
.
import CachiKit
let url = URL(fileURLWithPath: "path to the .xcresult")
let cachi = CachiKit(url: url)
let testSummaryIdentifier = ...
let testSummary = try? cachi.actionTestSummary(identifier: testSummaryIdentifier)
You can export attachments to filesystem
import CachiKit
let url = URL(fileURLWithPath: "path to the .xcresult")
let cachi = CachiKit(url: url)
let attachmentIdentifier = ...
let attachmentDestinationPath = ...
try? cachi.export(identifier: attachmentIdentifier, destinationPath: attachmentDestinationPath)
Contributions are welcome! If you have a bug to report, feel free to help out by opening a new issue or sending a pull request.
CachiKit is available under the Apache License, Version 2.0. See the LICENSE file for more info.