Skip to content

Deprecate XCTest test helpers in favor of Swift Testing - #957

Open
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch8from
bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers
Open

Deprecate XCTest test helpers in favor of Swift Testing#957
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch8from
bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers

Conversation

@bkhouri

@bkhouri bkhouri commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Now that all test suites in the repository have been migrated from
XCTest to Swift Testing, mark every XCTest-flavored public helper in
ArgumentParserTestHelpers as @available(*, deprecated, message: ...)
so downstream users see a compile-time nudge toward the
Swift-Testing-native replacement.

Deprecated helpers and their replacements:

  • TestableParsableArgumentsTestableSwiftTestingParsableArguments
  • TestableParsableCommandTestableSwiftTestingParsableCommand
  • XCTestExpectation.init(singleExpectation:)TestExpectation
  • AssertResultFailureexpectResultFailure
  • AssertErrorMessageexpectErrorMessage
  • AssertFullErrorMessageexpectFullErrorMessage
  • AssertParseexpectParse
  • AssertParseCommandexpectParseCommand
  • AssertParseCommandErrorMessage → (no direct replacement; inline
    with #expect / Issue.record)
  • AssertEqualStringsexpectEqualStrings
  • AssertExecuteCommandrequireExecuteCommand
  • AssertJSONEqualFromStringexpectJSONEqualFromString
  • assertSnapshotexpectSnapshot
  • assertGenerateManualexpectGenerateManual
  • assertGeneratedReferenceexpectGeneratedReference
  • assertDumpHelp(type:) / assertDumpHelp(command:)
    expectDumpHelp(type:) / expectDumpHelp(command:)
  • XCTest.debugURL — no public replacement; the Swift Testing helpers
    derive it internally via a Bundle-marker class.

To keep the deprecated helpers callable in-file without emitting
cascading deprecation warnings, extract their shared implementation
into non-deprecated fileprivate helpers (_AssertExecuteCommand,
_assertEqualStrings, _assertSnapshot, _debugBundleURL). The
public deprecated overloads forward to these.

The six expect* helpers in TestHelpers+SwiftTesting.swift no
longer delegate to their Assert* counterparts — inlining their
Swift-Testing branches lets us deprecate the Assert* variants
without warning at those call sites.

requireHelp moves from TestHelpers.swift to
TestHelpers+SwiftTesting.swift (it was already Swift-Testing-native)
and now calls expectEqualStrings instead of AssertEqualStrings.

Relates to #710

Checklist

  • I've added at least one test that validates that my change is working, if appropriate
  • I've followed the code style of the rest of the project
  • I've read the Contribution Guidelines
  • I've updated the documentation if necessary

Stack created with GitHub Stacks CLIGive Feedback 💬

@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 4258f6c to ccd4ed6 Compare August 25, 2026 03:26
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from ccd4ed6 to 01c0ad9 Compare August 25, 2026 03:34
@bkhouri
bkhouri marked this pull request as ready for review August 25, 2026 03:36
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 01c0ad9 to 2051f32 Compare August 25, 2026 03:54
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 2051f32 to d2d1b57 Compare August 25, 2026 03:56
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from d2d1b57 to c50e19e Compare August 25, 2026 04:01
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from c50e19e to c5d9fe0 Compare August 25, 2026 12:29
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch 6 times, most recently from 0f43db0 to cf1b364 Compare August 25, 2026 16:30
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from cf1b364 to 4045cf1 Compare August 26, 2026 06:37
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 4045cf1 to 7cd528e Compare August 26, 2026 06:41
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch 2 times, most recently from 288ff03 to b5e2ee4 Compare August 26, 2026 07:54
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from b5e2ee4 to f8dcf2f Compare August 26, 2026 18:18
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from f8dcf2f to 934af15 Compare August 26, 2026 19:55
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 934af15 to 607fdd3 Compare August 26, 2026 23:18
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 607fdd3 to 2d4464c Compare August 27, 2026 02:47
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 2d4464c to 4b93d04 Compare August 27, 2026 15:43
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from 4b93d04 to c4f48ef Compare August 27, 2026 15:52
@bkhouri bkhouri linked an issue Aug 27, 2026 that may be closed by this pull request
@bkhouri bkhouri removed a link to an issue Aug 27, 2026
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch 2 times, most recently from 3768ca1 to be95c26 Compare August 27, 2026 17:45
Now that all test suites in the repository have been migrated from
XCTest to Swift Testing, mark every XCTest-flavored public helper in
`ArgumentParserTestHelpers` as `@available(*, deprecated, message: ...)`
so downstream users see a compile-time nudge toward the
Swift-Testing-native replacement.

Deprecated helpers and their replacements:

- `TestableParsableArguments` → `TestableSwiftTestingParsableArguments`
- `TestableParsableCommand` → `TestableSwiftTestingParsableCommand`
- `XCTestExpectation.init(singleExpectation:)` → `TestExpectation`
- `AssertResultFailure` → `expectResultFailure`
- `AssertErrorMessage` → `expectErrorMessage`
- `AssertFullErrorMessage` → `expectFullErrorMessage`
- `AssertParse` → `expectParse`
- `AssertParseCommand` → `expectParseCommand`
- `AssertParseCommandErrorMessage` → (no direct replacement; inline
  with `#expect` / `Issue.record`)
- `AssertEqualStrings` → `expectEqualStrings`
- `AssertExecuteCommand` → `requireExecuteCommand`
- `AssertJSONEqualFromString` → `expectJSONEqualFromString`
- `assertSnapshot` → `expectSnapshot`
- `assertGenerateManual` → `expectGenerateManual`
- `assertGeneratedReference` → `expectGeneratedReference`
- `assertDumpHelp(type:)` / `assertDumpHelp(command:)` →
  `expectDumpHelp(type:)` / `expectDumpHelp(command:)`
- `XCTest.debugURL` — no public replacement; the Swift Testing helpers
  derive it internally via a `Bundle`-marker class.

To keep the deprecated helpers callable in-file without emitting
cascading deprecation warnings, extract their shared implementation
into non-deprecated `fileprivate` helpers (`_AssertExecuteCommand`,
`_assertEqualStrings`, `_assertSnapshot`, `_debugBundleURL`). The
public deprecated overloads forward to these.

The six `expect*` helpers in `TestHelpers+SwiftTesting.swift` no
longer delegate to their `Assert*` counterparts — inlining their
Swift-Testing branches lets us deprecate the `Assert*` variants
without warning at those call sites.

`requireHelp` moves from `TestHelpers.swift` to
`TestHelpers+SwiftTesting.swift` (it was already Swift-Testing-native)
and now calls `expectEqualStrings` instead of `AssertEqualStrings`.

Relates to #710
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_deprecate_xct_helpers branch from be95c26 to 8c2027c Compare August 27, 2026 17:54
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

Successfully merging this pull request may close these issues.

1 participant