Skip to content

Commit

Permalink
Added possibility to parse detailed report with implicit test ref id (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AllDmeat authored Dec 15, 2023
1 parent 8fcb242 commit f29382e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Sources/DBXCResultParser/Models/DTO/DTO+Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extension OverviewReportDTO {
}

extension DetailedReportDTO {
init(from xcresultPath: URL, refId: String) throws {
init(from xcresultPath: URL, refId: String? = nil) throws {
let refId = try (refId ?? OverviewReportDTO(from: xcresultPath).testsRefId)
let tempFilePath = try Constants.tempFilePath
try Shell.execute("xcrun xcresulttool get --path \(xcresultPath.relativePath) --format json --id \(refId) > \(tempFilePath.relativePath)")
let data = try Data(contentsOf: tempFilePath)
Expand Down
6 changes: 5 additions & 1 deletion Tests/DBXCResultParserTests/DetailedReportDTOTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ class DetailedReportDTOTests: XCTestCase {
try super.tearDownWithError()
}

func test() throws {
func test_parseWithExplicitRefId() throws {
let overviewReport = try OverviewReportDTO(from: Constants.unitTestsReportPath)
XCTAssertNoThrow(try DetailedReportDTO(from: Constants.unitTestsReportPath, refId: overviewReport.testsRefId))
}

func test_parseWithImplicitRefId() throws {
XCTAssertNoThrow(try DetailedReportDTO(from: Constants.unitTestsReportPath))
}
}

0 comments on commit f29382e

Please sign in to comment.