[SDTEST-3792] Rename XCTest retries so Xcode reports each as a distinct test#250
Merged
Merged
Conversation
…ct test Xcode dedupes a real retry failure against the prior run's expected failure when both runs share a test identity, which hid genuine failures emitted on the final attempt. Each retry now runs under an alias selector (testFoo_2, testFoo_3, ...) that forwards to the original method's IMP, so XCTest's invocation-derived -name makes Xcode treat every attempt as a separate test. The backend keeps the original name via the group's captured testId. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
calvinbayer
approved these changes
May 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
XCTestCase.addAlias(of:named:)(new, inXCTestExtensions.swift) registers an instance method whose IMP and type encoding are copied from the original test method. Works for sync,throws,async, and methods with return values.DDXCTestRetryGroup.retry()now allocates each retry instance with an alias selector (testFoo$2,testFoo$3, ...). XCTest's invocation-derived-namemakes Xcode treat each attempt as a separate test run.DDXCTestRetryGroup.perform(_:)uses the group's capturedtestId.test(original) forwithActiveTest(named:), so the backend keeps a stable test name across retries.tryinSwiftTestingTrait.prepare(test:)(the call no longer throws) and format elapsed time inLog.measurewith%.5f.Test plan
xcodebuild test -only-testing:DatadogSDKTestingTests/DDXCTestObserverTests -only-testing:DatadogSDKTestingTests/SwiftTestingTraitTests— green locallyasync/throwsXCTest retry to confirm the aliased selector dispatches correctly🤖 Generated with Claude Code