Skip to content

Migrate ArgumentParserUnitTests to Swift Testing - #954

Open
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch5from
bkhouri/t/main/migrate_tests_to_swift_testing_batch6
Open

Migrate ArgumentParserUnitTests to Swift Testing#954
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch5from
bkhouri/t/main/migrate_tests_to_swift_testing_batch6

Conversation

@bkhouri

@bkhouri bkhouri commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Migrate six ArgumentParserUnitTests suites from XCTest to Swift
Testing:

  • DefaultAsFlagCompletionTests
  • DefaultAsFlagDumpHelpTests
  • DumpHelpGenerationTests
  • ExitCodeTests
  • NameSpecificationTests
  • UsageGenerationTests

Add three new Swift Testing helpers to TestHelpers+SwiftTesting.swift
to unblock the dump-help and snapshot tests:

  • expectDumpHelp(type:) / expectDumpHelp(command:) — Swift Testing
    equivalents of assertDumpHelp, exercising the
    --experimental-dump-help path and comparing against
    Snapshots/*.json.
  • expectJSONEqualFromString(actual:expected:for:) — parses both sides
    as T: Codable & Equatable before #expect-ing equality.

NameSpecificationTests had Assert, Assert(names:expected:), and
AssertInvalid file-private XCTest helpers; port them to
expectNames / expectInvalid using #expect with a
SourceLocation parameter.

UsageGenerationTests had a _testSynopsis free function; port to
expectSynopsis using #expect.

ExitCodeTests keeps the NSError-specific test with all its
platform #if branches intact, converting each XCTAssertEqual to
#expect(a == b).

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_batch6 branch from 8bcc89d to 0e95990 Compare August 25, 2026 03:26
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 0e95990 to ffa782e Compare August 25, 2026 03:34
@bkhouri
bkhouri marked this pull request as ready for review August 25, 2026 03:37
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from ffa782e to 5645cbc Compare August 25, 2026 03:54
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 5645cbc to 3287ed3 Compare August 25, 2026 03:56
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch 3 times, most recently from a57e640 to 40b6272 Compare August 26, 2026 06:37
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch 2 times, most recently from e870a21 to 07df2f2 Compare August 26, 2026 07:49
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 07df2f2 to ea6a7ce Compare August 26, 2026 07:54
final class DefaultAsFlagCompletionTests: XCTestCase {
func testDefaultAsFlagCompletion_Bash() throws {
@Suite struct DefaultAsFlagCompletionTests {
@Test func testDefaultAsFlagCompletion_Bash() throws {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These few functions didn't lose the test prefix – could you check that across the different branches?

@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from ea6a7ce to b89c539 Compare August 26, 2026 18:18
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from b89c539 to 055aa9c Compare August 26, 2026 19:55
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 055aa9c to 9dcb4ef Compare August 26, 2026 23:18
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 9dcb4ef to 39f685a Compare August 27, 2026 02:47
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 39f685a to 11c93bf Compare August 27, 2026 15:43
Migrate six `ArgumentParserUnitTests` suites from XCTest to Swift
Testing:

- `DefaultAsFlagCompletionTests`
- `DefaultAsFlagDumpHelpTests`
- `DumpHelpGenerationTests`
- `ExitCodeTests`
- `NameSpecificationTests`
- `UsageGenerationTests`

Add three new Swift Testing helpers to `TestHelpers+SwiftTesting.swift`
to unblock the dump-help and snapshot tests:

- `expectDumpHelp(type:)` / `expectDumpHelp(command:)` — Swift Testing
  equivalents of `assertDumpHelp`, exercising the
  `--experimental-dump-help` path and comparing against
  `Snapshots/*.json`.
- `expectJSONEqualFromString(actual:expected:for:)` — parses both sides
  as `T: Codable & Equatable` before `#expect`-ing equality.

`NameSpecificationTests` had `Assert`, `Assert(names:expected:)`, and
`AssertInvalid` file-private XCTest helpers; port them to
`expectNames` / `expectInvalid` using `#expect` with a
`SourceLocation` parameter.

`UsageGenerationTests` had a `_testSynopsis` free function; port to
`expectSynopsis` using `#expect`.

`ExitCodeTests` keeps the `NSError`-specific test with all its
platform `#if` branches intact, converting each `XCTAssertEqual` to
`#expect(a == b)`.

Relates to #710
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch6 branch from 11c93bf to 36b827d Compare August 27, 2026 17:07
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.

2 participants