From 64fa2a3adcc89e1952b3e70b6c675a1e7740004d Mon Sep 17 00:00:00 2001 From: John Flanagan Date: Wed, 15 Oct 2025 10:34:46 -0500 Subject: [PATCH] Unify test case handling to fix missing isSkipped check --- Sources/xcresultparser/JunitXML.swift | 51 ++++++++++++++------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/Sources/xcresultparser/JunitXML.swift b/Sources/xcresultparser/JunitXML.swift index a85dad6..56362b9 100644 --- a/Sources/xcresultparser/JunitXML.swift +++ b/Sources/xcresultparser/JunitXML.swift @@ -258,19 +258,11 @@ public struct JunitXML: XmlSerializable { ) : group.testSuiteXML(numFormatter: numFormatter) for thisTest in tests { - let testcase = thisTest.xmlNode( + let testcase = createTestCase( + test: thisTest, classname: group.nameString, - numFormatter: numFormatter, - format: testReportFormat, - nodeNames: nodeNames + failureSummaries: failureSummaries ) - if thisTest.isFailed { - if let summary = thisTest.failureSummary(in: failureSummaries) { - testcase.addChild(summary.failureXML(projectRoot: projectRoot)) - } else { - testcase.addChild(failureWithoutSummary) - } - } node.addChild(testcase) } return node @@ -281,26 +273,37 @@ public struct JunitXML: XmlSerializable { ) -> [XMLElement] { var combined = [XMLElement]() for thisTest in tests { - let testcase = thisTest.xmlNode( + let testcase = createTestCase( + test: thisTest, classname: name, - numFormatter: numFormatter, - format: testReportFormat, - nodeNames: nodeNames + failureSummaries: failureSummaries ) - if thisTest.isFailed { - if let summary = thisTest.failureSummary(in: failureSummaries) { - testcase.addChild(summary.failureXML(projectRoot: projectRoot)) - } else { - testcase.addChild(failureWithoutSummary) - } - } else if thisTest.isSkipped { - testcase.addChild(skippedWithoutSummary) - } combined.append(testcase) } return combined } + private func createTestCase( + test: ActionTestMetadata, classname: String, failureSummaries: [TestFailureIssueSummary] + ) -> XMLElement { + let testcase = test.xmlNode( + classname: classname, + numFormatter: numFormatter, + format: testReportFormat, + nodeNames: nodeNames + ) + if test.isFailed { + if let summary = test.failureSummary(in: failureSummaries) { + testcase.addChild(summary.failureXML(projectRoot: projectRoot)) + } else { + testcase.addChild(failureWithoutSummary) + } + } else if test.isSkipped { + testcase.addChild(skippedWithoutSummary) + } + return testcase + } + private var failureWithoutSummary: XMLElement { return XMLElement(name: "failure") }