Skip to content

Migrate more end-to-end suites to Swift Testing - #951

Open
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch3from
bkhouri/t/main/migrate_tests_to_swift_testing_batch4
Open

Migrate more end-to-end suites to Swift Testing#951
bkhouri wants to merge 1 commit into
bkhouri/t/main/migrate_tests_to_swift_testing_batch3from
bkhouri/t/main/migrate_tests_to_swift_testing_batch4

Conversation

@bkhouri

@bkhouri bkhouri commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Migrate six ArgumentParserEndToEndTests suites from XCTest to Swift
Testing:

  • TransformEndToEndTests
  • OptionGroupEndToEndTests
  • ValidationEndToEndTests
  • OptionalEndToEndTests
  • PositionalEndToEndTests
  • SubcommandEndToEndTests

OptionGroupEndToEndTests and SubcommandEndToEndTests previously
relied on XCTestExpectation via the
TestableParsableArguments/TestableParsableCommand protocols. Add
Swift Testing counterparts to TestHelpers+SwiftTesting.swift:

  • TestExpectation: a reference-typed flag that carries a fulfilled
    bool. Since ArgumentParser's parse/validate/run pipeline is
    synchronous, we don't need a timeout-based expectation like
    XCTestExpectation.
  • TestableSwiftTestingParsableArguments /
    TestableSwiftTestingParsableCommand: mirror the XCTest protocols;
    their default validate() / run() fulfill didValidateExpectation
    / didRunExpectation, which tests then assert with
    #expect(command.didValidateExpectation.fulfilled).

Centralizing the type means future changes (e.g. moving to
confirmation, adding a counter, adding Sendable) touch only the
helper.

ValidationEndToEndTests's FooCommand.run() contained an inline
XCTAssertEqual; convert it to #expect(foo == bar) so the assertion
routes through Swift Testing when run under @Test.
SubcommandEndToEndTests's Math.run() gets the same treatment.

PositionalEndToEndTests keeps
disabled_parsing_BadlyFormedPositional as an untagged method
(matching the previous "not discovered" behavior of the disabled_
prefix under XCTest); its XCTFail becomes Issue.record.

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_batch4 branch from 4be63f5 to ee095f6 Compare August 22, 2026 01:46
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch 2 times, most recently from 8956649 to ccc1ae0 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_batch4 branch 2 times, most recently from 7c736bd to cde7e85 Compare August 25, 2026 03:56
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from cde7e85 to 297c241 Compare August 25, 2026 04:01
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from 297c241 to 1adb6d1 Compare August 26, 2026 06:37
// swift-format-ignore: AlwaysUseLowerCamelCase
// https://github.com/apple/swift-argument-parser/issues/710
extension SubcommandEndToEndTests {
final class SubcommandEndToEndTestsXCTest: XCTestCase {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm sure how to migrate this test to Swift Testing.

@natecook1000 @rauhul: Any ideas here?

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.

I'm not sure what exactly this is trying to test! I think we could just manually update a value in the validate() method and check that it worked. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The test is using XCTestExpection in SubSubCommand, which is indirectly a subcommand of BaseCommand. See right line 215.

I'm not familiar with XCTestExpectation.

@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from 1adb6d1 to d977102 Compare August 26, 2026 07:49
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from d977102 to 6590631 Compare August 26, 2026 07:54
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from 6590631 to 2753e72 Compare August 26, 2026 18:18
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch 2 times, most recently from 9d711c1 to f1fab87 Compare August 27, 2026 02:47
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from f1fab87 to 206ca59 Compare August 27, 2026 15:43
Migrate six `ArgumentParserEndToEndTests` suites from XCTest to Swift
Testing:

- `TransformEndToEndTests`
- `OptionGroupEndToEndTests`
- `ValidationEndToEndTests`
- `OptionalEndToEndTests`
- `PositionalEndToEndTests`
- `SubcommandEndToEndTests`

`OptionGroupEndToEndTests` and `SubcommandEndToEndTests` previously
relied on `XCTestExpectation` via the
`TestableParsableArguments`/`TestableParsableCommand` protocols. Add
Swift Testing counterparts to `TestHelpers+SwiftTesting.swift`:

- `TestExpectation`: a reference-typed flag that carries a `fulfilled`
  bool. Since ArgumentParser's parse/validate/run pipeline is
  synchronous, we don't need a timeout-based expectation like
  `XCTestExpectation`.
- `TestableSwiftTestingParsableArguments` /
  `TestableSwiftTestingParsableCommand`: mirror the XCTest protocols;
  their default `validate()` / `run()` fulfill `didValidateExpectation`
  / `didRunExpectation`, which tests then assert with
  `#expect(command.didValidateExpectation.fulfilled)`.

Centralizing the type means future changes (e.g. moving to
`confirmation`, adding a counter, adding Sendable) touch only the
helper.

`ValidationEndToEndTests`'s `FooCommand.run()` contained an inline
`XCTAssertEqual`; convert it to `#expect(foo == bar)` so the assertion
routes through Swift Testing when run under `@Test`.
`SubcommandEndToEndTests`'s `Math.run()` gets the same treatment.

`PositionalEndToEndTests` keeps
`disabled_parsing_BadlyFormedPositional` as an untagged method
(matching the previous "not discovered" behavior of the `disabled_`
prefix under XCTest); its `XCTFail` becomes `Issue.record`.

Relates to #710
@bkhouri
bkhouri force-pushed the bkhouri/t/main/migrate_tests_to_swift_testing_batch4 branch from 206ca59 to 2996d0c 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