Swiftpack.co - Package - davidahouse/XCResultKit

XCResultKit

This package provides some friendly Swift objects that map to the xcresult objects that you can access using the xcresulttool and xccov apps included in Xcode 11. Both of these apps provide export to JSON options, and this package provides all the JSON parsing required to turn the data into objects you can use.

XCResultFile

This is the main entry point for using the package. Just create an instance of this object with the path to the .xcresult you want to extract from:

let resultFile = XCResultFile(url: urlToXCResult)

Once you have created an instance, there are several methods to extract and parse the data. Note that these all shell out to run the xcresulttool or xccov so clearly this will not work on anything but macOS.

To get the ActionsInvocationRecord object (this is the top level object in the .xcresult file):

let invocationRecord = resultFile.getInvocationRecord()

Inside the invocation record you will find test plan run summaries id which you can use to get the details of what tests were ran:

let testPlanRunSummaries = resultFile.getTestPlanRunSummaries(id: "xxx")

You can get the details for an individual test:

let testSummary = resultFile.getActionTestSummary(id: "xxx")

Tests can also include attachments and with the payload ID you can either get the raw data, or export the contents to a file:

let payload = resultFile.getPayload(id: "123")
let exportedPath = resultFile.exportPayload(id: "123")

And you can also get the results of xccov using this simplified method:

let codeCoverage = resultFile.getCodeCoverage()

Github

link
Stars: 22

Dependencies

Used By

Total: 0

Releases

v0.7.1 - 2020-09-12 12:37:17

  • #31 ✨ Added platform section to Package.swift

v0.7.0 - 2020-04-21 11:42:10

  • [28] Implement testsSkippedCount which is new in Xcode 11.4

v0.6.0 - 2020-04-15 16:04:29

  • [27] Fix required properties for Xcode 11.4

v0.5.7 - 2020-02-28 22:02:43

  • [25] Fix export payload

v0.5.6 - 2020-02-28 14:27:53

  • [24] ♻️ Optimized handles for exportPayload method
  • [22] Codeable models pr

v0.5.5 - 2020-01-24 01:29:56

  • [21] Discard unnecessary conversions into UTF-8 strings

v0.5.4 - 2020-01-14 21:52:35

  • [20] Provide public initializers for CodeCoverage models

v0.5.3 - 2019-12-29 13:19:16

  • [18] add autoreleasepool for fixing crash in NSTask
  • [17] 🐎 Added swift test to PR checks
  • [15] 🚨 Swiftlint CA setup

v0.5.2 - 2019-11-07 22:58:16

  • [14] waiting until task actually completes before returning from xcrun method

v0.5.1 - 2019-10-29 17:06:00

  • [12] 🐎 Integrate stampede for pr checks and release notes
  • [11] ♻️ Renamed debug method to logError
  • [7] Added 2 undocumented default values

v0.5.0 - 2019-10-29 13:04:45

  • Now using xcrun directly instead of executing bash (thanks @cobbal!)

v0.4.0 - 2019-10-07 17:33:28

  • ActivityLog export and parsing now available! Thanks @felginep

v0.3.0 - 2019-10-04 19:25:33

  • Fixed the broken 0.2.0 release
  • Removed print statements in release builds
  • Ability to exporting files
  • More fixes and unit testing

More elements implemented - 2019-07-06 01:56:24

Initial release - 2019-07-04 14:43:38

  • Supports parsing ActionsInvocationRecord (returned with the basic get from xcresulttool
  • Supports parsing ActionTestPlanRunSummaries