Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Swift Testing in JunitReporter #325

Open
ikesyo opened this issue Oct 21, 2024 · 4 comments
Open

Support Swift Testing in JunitReporter #325

ikesyo opened this issue Oct 21, 2024 · 4 comments

Comments

@ikesyo
Copy link

ikesyo commented Oct 21, 2024

SwiftTesting*CaptureGroup should be handled at

if FailingTestCaptureGroup.regex.match(string: line) {
guard let testCase = generateFailingTest(line: line) else { return }
components.append(.failingTest(testCase))
} else if RestartingTestCaptureGroup.regex.match(string: line) {
guard let testCase = generateRestartingTest(line: line) else { return }
components.append(.failingTest(testCase))
} else if TestCasePassedCaptureGroup.regex.match(string: line) {
guard let testCase = generatePassingTest(line: line) else { return }
components.append(.testCasePassed(testCase))
} else if TestCaseSkippedCaptureGroup.regex.match(string: line) {
guard let testCase = generateSkippedTest(line: line) else { return }
components.append(.skippedTest(testCase))
} else if TestSuiteStartCaptureGroup.regex.match(string: line) {
guard let testStart = generateSuiteStart(line: line) else { return }
components.append(.testSuiteStart(testStart))
} else if ParallelTestCaseFailedCaptureGroup.regex.match(string: line) {
guard let testCase = generateParallelFailingTest(line: line) else { return }
parallelComponents.append(.failingTest(testCase))
} else if ParallelTestCasePassedCaptureGroup.regex.match(string: line) {
guard let testCase = generatePassingParallelTest(line: line) else { return }
parallelComponents.append(.testCasePassed(testCase))
} else if ParallelTestCaseSkippedCaptureGroup.regex.match(string: line) {
guard let testCase = generateSkippedParallelTest(line: line) else { return }
parallelComponents.append(.testCasePassed(testCase))
} else {
// Not needed for generating a junit report
return
}

@adarhef
Copy link

adarhef commented Dec 30, 2024

Could really use this. I don't know of any other way of getting JUnit reports using Xcode projects utilizing Swift Testing.

@Feako
Copy link

Feako commented Jan 23, 2025

I've encountered missing Swift Testing tests in the JUnit report when using xcbeautify. I'm a bit stuck because of this, and it would be really nice to see support for it. Just wanted to ask if you have any plans to address this in the near future. It would be very helpful.

@swhitty
Copy link

swhitty commented Jan 24, 2025

I'd love xcbeautify to support this but while waiting I'm using this workaround.

🧪 Swift Testing Workaround

Export JSON from xcresults:

% xcrun xcresulttool get test-results tests --path DerivedData/Logs/Test/Test-Project-2025.01.01_00-00-00-+0000.xcresult > results.json

Convert JSON to XML using something like my crude Swift script:

% ./junit.swift results.json > junit.xml

note: Swift Package Manager includes the --xunit-output result.xml option for direct junit export but xcodebuild does not.

@Feako
Copy link

Feako commented Jan 26, 2025

I'd love xcbeautify to support this but while waiting I'm using this workaround.

🧪 Swift Testing Workaround

This workaround works, thanks a lot @swhitty!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants