### Installation Source: https://context7.com/davidahouse/xcresultkit/llms.txt Add XCResultKit as a dependency to your Swift Package Manager project. ```APIDOC ## Installation Add XCResultKit as a Swift Package Manager dependency. ```swift // Package.swift let package = Package( name: "YourProject", platforms: [.macOS(.v10_15)], dependencies: [ .package(url: "https://github.com/davidahouse/XCResultKit", from: "1.0.0") ], targets: [ .target(name: "YourTarget", dependencies: ["XCResultKit"]) ] ) ``` ``` -------------------------------- ### Install XCResultKit via Swift Package Manager Source: https://context7.com/davidahouse/xcresultkit/llms.txt Add XCResultKit as a dependency in your Package.swift file to integrate it into your macOS project. ```swift let package = Package( name: "YourProject", platforms: [.macOS(.v10_15)], dependencies: [ .package(url: "https://github.com/davidahouse/XCResultKit", from: "1.0.0") ], targets: [ .target(name: "YourTarget", dependencies: ["XCResultKit"]) ] ) ``` -------------------------------- ### Get Test Plan Run Summaries in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Illustrates how to fetch test plan run summaries using an ID obtained from the invocation record. This provides details about the executed tests. ```swift let testPlanRunSummaries = resultFile.getTestPlanRunSummaries(id: "xxx") ``` -------------------------------- ### Get Individual Test Summary in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Demonstrates how to retrieve the summary for a specific test using its ID. This allows access to detailed information about a single test case. ```swift let testSummary = resultFile.getActionTestSummary(id: "xxx") ``` -------------------------------- ### GET /models/IssueSummary Source: https://github.com/davidahouse/xcresultkit/blob/main/XCResultFormat.md Retrieves details regarding specific issues identified during the build or test process, such as test failures or analyzer warnings. ```APIDOC ## GET /models/IssueSummary ### Description Represents a summary of an issue, including the type, error message, and the location within the source code where the issue occurred. ### Method GET ### Endpoint /models/IssueSummary ### Response #### Success Response (200) - **issueType** (String) - The category of the issue. - **message** (String) - Descriptive message of the issue. - **producingTarget** (String) - The build target that produced the issue. - **documentLocationInCreatingWorkspace** (DocumentLocation) - The file path and line number of the issue. #### Response Example { "issueType": "TestFailure", "message": "Assertion failed", "producingTarget": "MyAppTests", "documentLocationInCreatingWorkspace": { "url": "file:///path/to/test.swift", "concreteTypeName": "SourceCodeLocation" } } ``` -------------------------------- ### GET /models/ResultMetrics Source: https://github.com/davidahouse/xcresultkit/blob/main/XCResultFormat.md Retrieves the summary metrics for a test run, including counts for errors, warnings, and test execution status. ```APIDOC ## GET /models/ResultMetrics ### Description Provides a summary of test execution metrics including counts for analyzer warnings, errors, total tests, failed tests, and code coverage. ### Method GET ### Endpoint /models/ResultMetrics ### Response #### Success Response (200) - **analyzerWarningCount** (Int) - Number of analyzer warnings. - **errorCount** (Int) - Total number of errors. - **testsCount** (Int) - Total number of tests executed. - **testsFailedCount** (Int) - Total number of failed tests. - **testsSkippedCount** (Int) - Total number of skipped tests. - **warningCount** (Int) - Total number of warnings. - **totalCoveragePercentage** (Double) - Overall code coverage percentage. #### Response Example { "analyzerWarningCount": 0, "errorCount": 1, "testsCount": 50, "testsFailedCount": 1, "testsSkippedCount": 0, "warningCount": 5, "totalCoveragePercentage": 85.5 } ``` -------------------------------- ### Get Code Coverage Data in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Shows a simplified method to obtain code coverage results using the XCResultFile object. This leverages the xccov tool to gather coverage information. ```swift let codeCoverage = resultFile.getCodeCoverage() ``` -------------------------------- ### Get Invocation Record from XCResultFile in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Shows how to retrieve the top-level ActionsInvocationRecord object from an XCResultFile instance. This record contains essential information about the test execution. ```swift let invocationRecord = resultFile.getInvocationRecord() ``` -------------------------------- ### Handle Attachments in XCResultFile in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Explains how to get attachment payloads using their ID, either as raw data or by exporting them to a file. This is useful for accessing test artifacts. ```swift let payload = resultFile.getPayload(id: "123") let exportedPath = resultFile.exportPayload(id: "123") ``` -------------------------------- ### getInvocationRecord() - Access Top-Level Test Data Source: https://context7.com/davidahouse/xcresultkit/llms.txt Returns the ActionsInvocationRecord, the root object containing all test actions, metrics, and issue summaries. This is your starting point for accessing test results. ```APIDOC ## getInvocationRecord() - Access Top-Level Test Data Returns the `ActionsInvocationRecord` which is the root object containing all test actions, metrics, and issue summaries. This is typically your starting point for accessing test results. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) // Get the top-level invocation record guard let invocationRecord = resultFile.getInvocationRecord() else { print("Failed to parse xcresult file") return } // Access overall metrics let metrics = invocationRecord.metrics print("Total tests: \(metrics.testsCount ?? 0)") print("Tests failed: \(metrics.testsFailedCount ?? 0)") print("Tests skipped: \(metrics.testsSkippedCount ?? 0)") print("Warnings: \(metrics.warningCount ?? 0)") print("Errors: \(metrics.errorCount ?? 0)") // Access issue summaries let issues = invocationRecord.issues for error in issues.errorSummaries { print("Error: \(error.message)") } for failure in issues.testFailureSummaries { print("Test failure: \(failure.message)") } // Iterate through actions (build, test, etc.) for action in invocationRecord.actions { print("Action: \(action.schemeCommandName) - \(action.schemeTaskName)") print(" Started: \(action.startedTime)") print(" Ended: \(action.endedTime)") print(" Status: \(action.actionResult.status)") // Access run destination info let destination = action.runDestination print(" Device: \(destination.localComputerRecord.name)") print(" Platform: \(destination.targetSDKRecord.name)") } ``` ``` -------------------------------- ### Get Raw Attachment Data with getPayload Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves the raw Data for an attachment payload using its ID. This is useful for in-memory processing of attachment data, such as images or text content, without needing to write to disk. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) // Assuming you have a payload ID from an attachment let payloadId = "0~abc123..." if let payloadData = resultFile.getPayload(id: payloadId) { print("Payload size: \(payloadData.count) bytes") // Process the data (e.g., for images) // let image = NSImage(data: payloadData) // Or convert to string for text attachments if let textContent = String(data: payloadData, encoding: .utf8) { print("Text content: \(textContent)") } } ``` -------------------------------- ### Initialize XCResultFile in Swift Source: https://github.com/davidahouse/xcresultkit/blob/main/README.md Demonstrates how to create an instance of XCResultFile, which is the main entry point for using the package. This object is initialized with the URL of the .xcresult file to be processed. ```swift let resultFile = XCResultFile(url: urlToXCResult) ``` -------------------------------- ### XCResultFile - Main Entry Point Source: https://context7.com/davidahouse/xcresultkit/llms.txt The XCResultFile class is the primary interface for accessing xcresult data. Initialize it with a URL pointing to your .xcresult bundle. ```APIDOC ## XCResultFile - Main Entry Point The `XCResultFile` class is the primary interface for accessing xcresult data. Initialize it with a URL pointing to your `.xcresult` bundle and use its methods to extract various types of data. ```swift import XCResultKit // Initialize with path to xcresult file let resultURL = URL(fileURLWithPath: "/path/to/TestResults.xcresult") let resultFile = XCResultFile(url: resultURL) // Access the URL property if needed print("Analyzing: \(resultFile.url.path)") ``` ``` -------------------------------- ### Retrieve and Iterate Test Plan Run Summaries in Swift Source: https://context7.com/davidahouse/xcresultkit/llms.txt This snippet demonstrates how to initialize an XCResultFile, locate test actions within an invocation record, and traverse the hierarchy of test plan summaries, targets, test classes, and individual test methods. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) guard let invocationRecord = resultFile.getInvocationRecord() else { return } for action in invocationRecord.actions where action.schemeCommandName == "Test" { guard let testsRefId = action.actionResult.testsRef?.id, let testPlanSummaries = resultFile.getTestPlanRunSummaries(id: testsRefId) else { continue } for summary in testPlanSummaries.summaries { print("Test Plan: \(summary.name ?? "Unknown")") for testableSummary in summary.testableSummaries { print(" Target: \(testableSummary.targetName ?? "Unknown")") print(" Test Kind: \(testableSummary.testKind ?? "Unknown")") for testGroup in testableSummary.tests { print(" Test Class: \(testGroup.name ?? "Unknown")") print(" Duration: \(testGroup.duration)s") for test in testGroup.subtests { let status = test.testStatus let duration = test.duration ?? 0 print(" \(test.name ?? "Unknown"): \(status) (\(duration)s)") } for subgroup in testGroup.subtestGroups { print(" Subgroup: \(subgroup.name ?? "Unknown")") } } for globalTest in testableSummary.globalTests { print(" Global Test: \(globalTest.name ?? "Unknown")") } } } } ``` -------------------------------- ### Export Test Attachments using XCResultKit Source: https://context7.com/davidahouse/xcresultkit/llms.txt Demonstrates how to iterate through test summaries and activity attachments within an XCResult file to export them to a local directory. It requires an initialized XCResultFile instance and handles file system operations for output. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) let outputDir = URL(fileURLWithPath: "/path/to/screenshots") try? FileManager.default.createDirectory(at: outputDir, withIntermediateDirectories: true) guard let invocationRecord = resultFile.getInvocationRecord() else { return } for action in invocationRecord.actions where action.schemeCommandName == "Test" { guard let testsRefId = action.actionResult.testsRef?.id, let testPlanSummaries = resultFile.getTestPlanRunSummaries(id: testsRefId) else { continue } for summary in testPlanSummaries.summaries { for testableSummary in summary.testableSummaries { for testGroup in testableSummary.tests { for test in testGroup.subtests { guard let summaryId = test.summaryRef?.id, let testSummary = resultFile.getActionTestSummary(id: summaryId) else { continue } for activity in testSummary.activitySummaries { for attachment in activity.attachments { resultFile.exportAttachment(attachment: attachment, outputPath: outputDir.path) } } } } } } } ``` -------------------------------- ### Access Build and Test Logs with getLogs Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves activity log sections containing build logs, warnings, errors, and diagnostic messages. It requires the log reference ID obtained from an action's result. The function returns log sections that can be further processed for messages and subsections. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) guard let invocationRecord = resultFile.getInvocationRecord() else { return } for action in invocationRecord.actions { guard let logRefId = action.actionResult.logRef?.id, let logSection = resultFile.getLogs(id: logRefId) else { continue } print("Log Section: \(logSection.title)") print(" Domain: \(logSection.domainType)") print(" Duration: \(logSection.duration)s") print(" Result: \(logSection.result ?? "Unknown")") // Process messages (warnings, errors, notes) for message in logSection.messages { print(" Message: \(message.title)") print(" Type: \(message.type)") if let location = message.location { print(" Location: \(location.url)") } } // Recursively process subsections func processSubsections(_ sections: [ActivityLogSection], indent: String = " ") { for subsection in sections { print("\(indent)Subsection: \(subsection.title)") print("\(indent) Duration: \(subsection.duration)s") print("\(indent) Result: \(subsection.result ?? "N/A")") for message in subsection.messages { print("\(indent) Message: \(message.title)") } processSubsections(subsection.subsections, indent: indent + " ") } } processSubsections(logSection.subsections) } ``` -------------------------------- ### Export Full Test Results as JSON Source: https://context7.com/davidahouse/xcresultkit/llms.txt Shows how to serialize the entire invocation record into a JSON format. This is useful for archiving test data or integrating with external reporting systems. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) if let jsonData = resultFile.exportRecursiveJson() { let outputURL = URL(fileURLWithPath: "/path/to/results.json") try? jsonData.write(to: outputURL) if let jsonString = String(data: jsonData, encoding: .utf8) { print(jsonString) } } ``` -------------------------------- ### Generate Test Report from XCResult Bundle Source: https://context7.com/davidahouse/xcresultkit/llms.txt This snippet demonstrates how to parse an .xcresult file to extract test counts, duration, code coverage, and detailed failure information. It uses the XCResultKit API to traverse invocation records and test summaries. ```swift import XCResultKit import Foundation struct TestReport { let totalTests: Int let passedTests: Int let failedTests: Int let skippedTests: Int let duration: TimeInterval let codeCoverage: Double? let failures: [(testName: String, message: String, file: String?)] } func generateTestReport(from xcresultPath: String) -> TestReport? { let resultFile = XCResultFile(url: URL(fileURLWithPath: xcresultPath)) guard let invocation = resultFile.getInvocationRecord() else { print("Failed to parse xcresult") return nil } let metrics = invocation.metrics let totalTests = metrics.testsCount ?? 0 let failedTests = metrics.testsFailedCount ?? 0 let skippedTests = metrics.testsSkippedCount ?? 0 let passedTests = totalTests - failedTests - skippedTests var totalDuration: TimeInterval = 0 for action in invocation.actions { totalDuration += action.endedTime.timeIntervalSince(action.startedTime) } let coverage = resultFile.getCodeCoverage()?.lineCoverage var failures: [(String, String, String?)] = [] for action in invocation.actions where action.schemeCommandName == "Test" { guard let testsRefId = action.actionResult.testsRef?.id, let testPlanSummaries = resultFile.getTestPlanRunSummaries(id: testsRefId) else { continue } for summary in testPlanSummaries.summaries { for testableSummary in summary.testableSummaries { for testGroup in testableSummary.tests { for test in testGroup.subtests where test.testStatus == "Failure" { guard let summaryId = test.summaryRef?.id, let testSummary = resultFile.getActionTestSummary(id: summaryId) else { continue } for failure in testSummary.failureSummaries { let file = failure.documentLocationInCreatingWorkspace?.url failures.append((test.name ?? "Unknown", failure.message, file)) } } } } } } return TestReport( totalTests: totalTests, passedTests: passedTests, failedTests: failedTests, skippedTests: skippedTests, duration: totalDuration, codeCoverage: coverage, failures: failures ) } ``` -------------------------------- ### Access Individual Test Details with getActionTestSummary Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves detailed information for a specific test, including its status, duration, failures, and activities. It requires the test's summary reference ID. Dependencies include XCResultKit and standard Swift libraries. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) guard let invocationRecord = resultFile.getInvocationRecord() else { return } for action in invocationRecord.actions where action.schemeCommandName == "Test" { guard let testsRefId = action.actionResult.testsRef?.id, let testPlanSummaries = resultFile.getTestPlanRunSummaries(id: testsRefId) else { continue } for summary in testPlanSummaries.summaries { for testableSummary in summary.testableSummaries { for testGroup in testableSummary.tests { for test in testGroup.subtests { // Get detailed test summary using summaryRef guard let summaryId = test.summaryRef?.id, let testSummary = resultFile.getActionTestSummary(id: summaryId) else { continue } print("Test: \(testSummary.name ?? \"Unknown\")") print(" Status: \(testSummary.testStatus)") print(" Duration: \(testSummary.duration)s") // Access failure summaries for failure in testSummary.failureSummaries { print(" Failure: \(failure.message)") if let location = failure.documentLocationInCreatingWorkspace { print(" File: \(location.url)") } } // Access expected failures (XCTExpectFailure) for expectedFailure in testSummary.expectedFailures { print(" Expected Failure: \(expectedFailure.failureReason ?? \"Unknown\")") } // Access skip notice if let skipNotice = testSummary.skipNoticeSummary { print(" Skipped: \(skipNotice.message ?? \"Unknown reason\")") } // Access performance metrics for metric in testSummary.performanceMetrics { print(" Performance: \(metric.displayName) = \(metric.unitOfMeasurement)") } // Access activity summaries (test steps/actions) for activity in testSummary.activitySummaries { print(" Activity: \(activity.title)") print(" Attachments: \(activity.attachments.count)") } } } } } } ``` -------------------------------- ### getLogs(id:) Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves activity log sections including build logs, warnings, and errors from a specific log reference ID. ```APIDOC ## GET getLogs(id:) ### Description Returns activity log sections containing build logs, warnings, errors, and diagnostic messages. Use the logRef.id from an action's result to retrieve logs. ### Method GET ### Endpoint getLogs(id: String) ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier for the log reference. ### Response #### Success Response (200) - **ActivityLogSection** (Object) - The root log section containing messages and subsections. ``` -------------------------------- ### Access Code Coverage Data with getCodeCoverage Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves code coverage metrics, including line coverage percentages for targets, files, and functions. It parses data from xccov files. Dependencies include XCResultKit and standard Swift libraries. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) guard let codeCoverage = resultFile.getCodeCoverage() else { print("No code coverage data available") return } // Overall coverage metrics print("Overall Coverage: \(codeCoverage.lineCoverage * 100)%\n") print("Covered Lines: \(codeCoverage.coveredLines)/\(codeCoverage.executableLines)\n") // Coverage by target for target in codeCoverage.targets { print("\nTarget: \(target.name)") print(" Coverage: \(String(format: \"%%.1f\", target.lineCoverage * 100))%\n") print(" Lines: \(target.coveredLines)/\(target.executableLines)\n") // Coverage by file for file in target.files { print(" File: \(file.name)\n") print(" Coverage: \(String(format: \"%%.1f\", file.lineCoverage * 100))%\n") print(" Path: \(file.path)\n") // Coverage by function for function in file.functions { print(" \(function.name): \(String(format: \"%%.1f\", function.lineCoverage * 100))%\n") print(" Line: \(function.lineNumber), Executions: \(function.executionCount)\n") } } } // Find files with adequate coverage (80%+) let wellCoveredFiles = codeCoverage.filesCoveredAdequately() print("\nFiles with 80%+ coverage: \(wellCoveredFiles.count)\n") // Find files with no coverage let uncoveredFiles = codeCoverage.filesWithNoCoverage() print("Files with 0% coverage: \(uncoveredFiles.count)\n") // Find specific file coverage if let specificFile = codeCoverage.fileMatching(target: "MyApp", name: "ViewController.swift") { print("ViewController.swift coverage: \(specificFile.lineCoverage * 100)%") } ``` -------------------------------- ### Xcode Result Types Overview Source: https://github.com/davidahouse/xcresultkit/blob/main/XCResultFormat.md This section details the structure of various result types used in Xcode, such as ActionDeviceRecord, ActionRunDestinationRecord, and ActionResult. ```APIDOC ## Xcode Result Types API Documentation This API provides a structured way to access and interpret Xcode build and test results. ### Data Types This API defines several object types for representing different aspects of Xcode results: * **ActionAbstractTestSummary**: Represents an abstract summary for test actions. * `name` (String?): The name of the test summary. * **ActionDeviceRecord**: Represents a record of a device used during an action. * `name` (String): The name of the device. * `isConcreteDevice` (Bool): Indicates if the device is a concrete device. * `operatingSystemVersion` (String): The operating system version of the device. * `operatingSystemVersionWithBuildNumber` (String): OS version with build number. * `nativeArchitecture` (String): The native architecture of the device. * `modelName` (String): The model name of the device. * `modelCode` (String): The model code of the device. * `modelUTI` (String): The model UTI of the device. * `identifier` (String): The unique identifier of the device. * `isWireless` (Bool): Indicates if the device is wireless. * `cpuKind` (String): The kind of CPU. * `cpuCount` (Int?): The number of CPUs. * `cpuSpeedInMHz` (Int?): The CPU speed in MHz. * `busSpeedInMHz` (Int?): The bus speed in MHz. * `ramSizeInMegabytes` (Int?): The RAM size in MB. * `physicalCPUCoresPerPackage` (Int?): Physical CPU cores per package. * `logicalCPUCoresPerPackage` (Int?): Logical CPU cores per package. * `platformRecord` (ActionPlatformRecord): Record of the platform. * **ActionPlatformRecord**: Represents a record of the platform. * `identifier` (String): The unique identifier of the platform. * `userDescription` (String): A user-friendly description of the platform. * **ActionRecord**: Represents a record of an action performed. * `schemeCommandName` (String): The name of the scheme command. * `schemeTaskName` (String): The name of the scheme task. * `title` (String?): The title of the action. * `startedTime` (Date): The start time of the action. * `endedTime` (Date): The end time of the action. * `runDestination` (ActionRunDestinationRecord): The run destination record. * `buildResult` (ActionResult): The build result. * `actionResult` (ActionResult): The action result. * `testPlanName` (String?): The name of the test plan. * **ActionResult**: Represents the result of an action. * `resultName` (String): The name of the result. * `status` (String): The status of the result (e.g., "Success", "Failure"). * `metrics` (ResultMetrics): Metrics associated with the result. * `issues` (ResultIssueSummaries): Summaries of issues. * `coverage` (CodeCoverageInfo): Code coverage information. * `timelineRef` (Reference?): Reference to the timeline. * `logRef` (Reference?): Reference to the log. * `testsRef` (Reference?): Reference to the tests. * `diagnosticsRef` (Reference?): Reference to diagnostics. * `consoleLogRef` (Reference?): Reference to the console log. * **ActionRunDestinationRecord**: Represents the destination where an action was run. * `displayName` (String): The display name of the destination. * `targetArchitecture` (String): The target architecture. * `targetDeviceRecord` (ActionDeviceRecord): Record of the target device. * `localComputerRecord` (ActionDeviceRecord): Record of the local computer. * `targetSDKRecord` (ActionSDKRecord): Record of the target SDK. * **ActionSDKRecord**: Represents a record of an SDK. * `name` (String): The name of the SDK. * `identifier` (String): The unique identifier of the SDK. * `operatingSystemVersion` (String): The operating system version of the SDK. * `isInternal` (Bool): Indicates if the SDK is internal. * **ActionTestActivitySummary**: Represents a summary of test activities. * `title` (String): The title of the activity. * `activityType` (String): The type of activity. * `uuid` (String): The unique identifier of the activity. * `start` (Date?): The start time of the activity. * `finish` (Date?): The finish time of the activity. * `attachments` ([ActionTestAttachment]): Attachments for the activity. * `subactivities` ([ActionTestActivitySummary]): Subactivities of this activity. * `failureSummaryIDs` ([String]): IDs of failure summaries. * `expectedFailureIDs` ([String]): IDs of expected failures. * `warningSummaryIDs` ([String]): IDs of warning summaries. * **ActionTestAttachment**: Represents an attachment for a test. * `uniformTypeIdentifier` (String): The uniform type identifier of the attachment. * `name` (String?): The name of the attachment. * `uuid` (String?): The unique identifier of the attachment. * `timestamp` (Date?): The timestamp of the attachment. * `userInfo` (SortedKeyValueArray?): User info associated with the attachment. * `lifetime` (String): The lifetime of the attachment. * `inActivityIdentifier` (Int): The identifier of the activity the attachment belongs to. * `filename` (String?): The filename of the attachment. * `payloadRef` (Reference?): Reference to the attachment payload. * `payloadSize` (Int): The size of the attachment payload. * **ActionTestConfiguration**: Represents a test configuration. * `values` (SortedKeyValueArray): Key-value pairs representing the configuration. * **ActionTestExpectedFailure**: Represents an expected failure in a test. * `uuid` (String): The unique identifier of the expected failure. * `failureReason` (String?): The reason for the expected failure. * `failureSummary` (ActionTestFailureSummary?): Summary of the failure. * `isTopLevelFailure` (Bool): Indicates if it's a top-level failure. * **ActionTestFailureSummary**: Represents a summary of a test failure. * `message` (String?): The failure message. * `fileName` (String): The file where the failure occurred. * `lineNumber` (Int): The line number of the failure. * `isPerformanceFailure` (Bool): Indicates if it's a performance failure. * `uuid` (String): The unique identifier of the failure summary. * `issueType` (String?): The type of issue. * `detailedDescription` (String?): A detailed description of the failure. * `attachments` ([ActionTestAttachment]): Attachments related to the failure. * `associatedError` (TestAssociatedError?): Associated error information. * `sourceCodeContext` (SourceCodeContext?): Source code context of the failure. * `timestamp` (Date?): The timestamp of the failure. * `isTopLevelFailure` (Bool): Indicates if it's a top-level failure. * `expression` (TestExpression?): The test expression that failed. * **ActionTestIssueSummary**: Represents a summary of a test issue. * `message` (String?): The issue message. * `fileName` (String): The file where the issue occurred. * `lineNumber` (Int): The line number of the issue. * `uuid` (String): The unique identifier of the issue summary. * `issueType` (String?): The type of issue. * `detailedDescription` (String?): A detailed description of the issue. * `attachments` ([ActionTestAttachment]): Attachments related to the issue. * `associatedError` (TestAssociatedError?): Associated error information. * `sourceCodeContext` (SourceCodeContext?): Source code context of the issue. * `timestamp` (Date?): The timestamp of the issue. * **ActionTestMetadata**: Represents metadata for a test. * `testStatus` (String): The status of the test. * `duration` (Double?): The duration of the test. * `summaryRef` (Reference?): Reference to the test summary. * `performanceMetricsCount` (Int): Number of performance metrics. * `failureSummariesCount` (Int): Number of failure summaries. * `activitySummariesCount` (Int): Number of activity summaries. * **ActionTestNoticeSummary**: Represents a notice related to a test. * `message` (String?): The notice message. * `fileName` (String): The file where the notice occurred. * `lineNumber` (Int): The line number of the notice. * `timestamp` (Date?): The timestamp of the notice. * **ActionTestPerformanceMetricSummary**: Represents a summary of performance metrics for a test. * `displayName` (String): The display name of the metric. * `unitOfMeasurement` (String): The unit of measurement for the metric. * `measurements` ([Double]): The recorded measurements. * `identifier` (String?): The identifier of the metric. * `baselineName` (String?): The name of the baseline. * `baselineAverage` (Double?): The average value of the baseline. * `maxPercentRegression` (Double?): Maximum percentage regression allowed. * `maxPercentRelativeStandardDeviation` (Double?): Maximum relative standard deviation percentage. * `maxRegression` (Double?): Maximum regression value. * `maxStandardDeviation` (Double?): Maximum standard deviation value. * `polarity` (String?): Polarity of the metric (e.g., "HigherIsBetter", "LowerIsBetter"). * **ActionTestPlanRunSummaries**: Represents summaries for a test plan run. * `summaries` ([ActionTestPlanRunSummary]): A list of test plan run summaries. ``` -------------------------------- ### Retrieve Invocation Record and Metrics Source: https://context7.com/davidahouse/xcresultkit/llms.txt Use getInvocationRecord to access the root object of the result file, allowing you to inspect test metrics, issue summaries, and action details. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) guard let invocationRecord = resultFile.getInvocationRecord() else { print("Failed to parse xcresult file") return } let metrics = invocationRecord.metrics print("Total tests: \(metrics.testsCount ?? 0)") for action in invocationRecord.actions { print("Action: \(action.schemeCommandName) - \(action.schemeTaskName)") } ``` -------------------------------- ### Export Attachment to Temporary File with exportPayload Source: https://context7.com/davidahouse/xcresultkit/llms.txt Exports an attachment to a temporary file and returns its URL. This method is convenient for quickly extracting attachments when the output location is not critical. The caller is responsible for cleaning up the temporary file. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) // Export payload to temp directory let payloadId = "0~abc123..." if let tempURL = resultFile.exportPayload(id: payloadId) { print("Exported to: \(tempURL.path)") // Use the file // let image = NSImage(contentsOf: tempURL) // Clean up when done try? FileManager.default.removeItem(at: tempURL) } ``` -------------------------------- ### Export Attachment to Specific Path with exportAttachment Source: https://context7.com/davidahouse/xcresultkit/llms.txt Exports an attachment to a specified path, allowing control over whether it's exported as a file or a directory. The output directory must exist prior to calling this method. This is useful for handling different attachment types like screenshots or test bundle resources. ```swift import XCResultKit let resultFile = XCResultFile(url: URL(fileURLWithPath: "/path/to/Test.xcresult")) // Create output directory let outputDir = URL(fileURLWithPath: "/path/to/exports") try? FileManager.default.createDirectory(at: outputDir, withIntermediateDirectories: true) // Export as file let payloadId = "0~abc123..." let outputPath = outputDir.appendingPathComponent("screenshot.png").path resultFile.exportAttachment( id: payloadId, outputPath: outputPath, type: .file ) // Export as directory (for bundle attachments) let bundleOutputPath = outputDir.appendingPathComponent("TestBundle").path resultFile.exportAttachment( id: payloadId, outputPath: bundleOutputPath, type: .directory ) ``` -------------------------------- ### TypeDefinition Data Model Source: https://github.com/davidahouse/xcresultkit/blob/main/XCResultFormat.md Defines the structure and inheritance of types within the result bundle. ```APIDOC ## TypeDefinition Model ### Description Defines the schema for a specific type, including its name and optional supertype. ### Properties - **name** (String) - The name of the type. - **supertype** (TypeDefinition?) - The parent type if inheritance is present. ``` -------------------------------- ### exportPayload(id:) Source: https://context7.com/davidahouse/xcresultkit/llms.txt Exports an attachment to a temporary file location. ```APIDOC ## POST exportPayload(id:) ### Description Exports an attachment to a temporary file and returns the URL. Useful for quickly extracting attachments when you don't need control over the output location. ### Method POST ### Endpoint exportPayload(id: String) ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier for the attachment payload. ### Response #### Success Response (200) - **URL** (Object) - The file system URL where the attachment was exported. ``` -------------------------------- ### exportAttachment(id:outputPath:type:) Source: https://context7.com/davidahouse/xcresultkit/llms.txt Exports an attachment to a specified file system path with configurable type. ```APIDOC ## POST exportAttachment(id:outputPath:type:) ### Description Exports an attachment to a specified path with control over the export type (file or directory). ### Method POST ### Endpoint exportAttachment(id: String, outputPath: String, type: AttachmentType) ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier for the attachment. - **outputPath** (String) - Required - The target file system path. - **type** (Enum) - Required - The type of export: .file or .directory. ### Response #### Success Response (200) - **Void** - Returns successfully upon completion. ``` -------------------------------- ### TestValue Data Model Source: https://github.com/davidahouse/xcresultkit/blob/main/XCResultFormat.md Represents a test value node within the XCResult hierarchy, containing metadata about the type and its children. ```APIDOC ## TestValue Model ### Description Represents a node in the test result tree, providing information about the data type and nested children. ### Properties - **description** (String) - The text description of the value. - **debugDescription** (String?) - Optional detailed debug information. - **typeName** (String?) - The name of the data type. - **fullyQualifiedTypeName** (String?) - The full namespace-qualified type name. - **label** (String?) - The label associated with the value. - **isCollection** (Bool) - Indicates if this node is a collection. - **children** (TestValue?) - Nested child nodes. ``` -------------------------------- ### getPayload(id:) Source: https://context7.com/davidahouse/xcresultkit/llms.txt Retrieves the raw data of an attachment payload directly into memory. ```APIDOC ## GET getPayload(id:) ### Description Returns the raw Data for an attachment payload. Use this when you need to process attachment data in memory without writing to disk. ### Method GET ### Endpoint getPayload(id: String) ### Parameters #### Path Parameters - **id** (String) - Required - The unique identifier for the attachment payload. ### Response #### Success Response (200) - **Data** (Object) - The raw binary data of the attachment. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.