-
Notifications
You must be signed in to change notification settings - Fork 108
Crashing tests result in empty xunit output with Swift Testing #1110
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
Comments
Here's the full command line output when running
|
Verified that this also repros with Xcode 16.3
|
swift-package-manager delegates the creation of the XML results to swift-testing. Because results are written by swift-testing itself, when the process crashes it cannot write out results. I'm going to move this issue to the swift-testing repository. |
Thanks @plemarquand for the details and triaging.
By chance, do you happen to have a pointer to where swift-testing writes out the XML report? If not, no big deal, but I was curious to look a bit deeper. |
@bachand sure, the code that produces the xml can be found here https://github.com/swiftlang/swift-testing/blob/main/Sources/Testing/Events/Recorder/Event.JUnitXMLRecorder.swift#L98 |
We have some plans to rearchitect how JUnit XML is produced for Swift Testing tests such that it would be done via a supervisory process rather than in the same process where tests are running. That should address this problem by ensuring that a crash in the test runner process is correctly represented in the results XML file and that the final file is still valid. We should dupe this to the issue tracking that effort, or create an issue to track that if none exists yet. |
Nice! This would be great. 😃 |
In an effort to be helpful, I can share the context that this limitation of Swift Testing has made it challenging for us to roll out Swift Testing at scale, as we have a limited ability to disable crashing tests in our large codebase as we try to keep CI builds for the app green. The supervisory process approach makes a lot of sense to me. Thanks for taking a look at this issue — we appreciate it! |
Is it reproducible with SwiftPM command-line tools:
swift build
,swift test
,swift package
etc?swift build
,swift test
,swift package
etc.Description
I wrote a small test in both XCTest and Swift Testing
I put these in a small Swift Package as a test target, and ran using
swift test --parallel --xunit-output xunit.xml
Expected behavior
The resulting xunit-swift-testing.xml should report always_pass() as passing, always_fail() as failing, and crashing_test() as failing as well. This would match the behavior of the equivalent XCTestCase.
Actual behavior
The xunit-swift-testing.xml contains only:
While the xunit.xml file contains:
Steps to reproduce
Here's my package file:
The two tests are contained in a
Tests/
folder in separate files, while theSources/
folder contains the default starter code for a command-line tool:Swift Package Manager version/commit hash
6.0
Swift & OS version (output of
swift --version ; uname -a
)swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Darwin Andys-MacBook-Pro.local 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:22 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6041 arm64
The text was updated successfully, but these errors were encountered: