Skip to content

Refactor testing utilities#56

Merged
aryan-25 merged 16 commits intoswift-server:mainfrom
aryan-25:refactor-testing-utils
Feb 26, 2026
Merged

Refactor testing utilities#56
aryan-25 merged 16 commits intoswift-server:mainfrom
aryan-25:refactor-testing-utils

Conversation

@aryan-25
Copy link
Collaborator

@aryan-25 aryan-25 commented Feb 12, 2026

Motivation:

We currently have two mechanisms for testing NIOHTTPServer in an end-to-end manner. The first mechanism involves starting up NIOHTTPServer on localhost, and setting up a NIO client (backed by NIO's ClientBootstrap) to send requests / observe responses. The second mechanism involves spoofing a NIOAsyncTestingChannel as the channel NIOHTTPServer runs on, wiring a client channel (also backed by a NIOAsyncTestingChannel) to the server channel, and writing/reading to/from the client channel.

Currently, both mechanisms share some duplicated code, have no documentation, and in general are poorly named/structured. We should improve this.

Modifications:

  • Functionality of the existing Client type broken down into extensions on Channel and ClientBootstrap.

    • This enables code re-use in the client setup for the NIOAsyncTestingChannel-based mechanism.
  • The NIOAsyncTestingChannel-based mechanism is now structured into TestingChannelHTTP1Server and TestingChannelSecureUpgradeServer.

  • Added documentation for all test utilities and some general refactoring.

Result:

Easier to write more involving tests.

@aryan-25 aryan-25 added the semver/none No version bump required. label Feb 12, 2026
@gjcairo gjcairo self-requested a review February 12, 2026 11:21
@gjcairo gjcairo removed their assignment Feb 12, 2026
@aryan-25 aryan-25 requested a review from gjcairo February 20, 2026 14:53
@aryan-25 aryan-25 requested a review from gjcairo February 24, 2026 09:59
@aryan-25 aryan-25 merged commit c7fb090 into swift-server:main Feb 26, 2026
23 of 26 checks passed
@aryan-25 aryan-25 deleted the refactor-testing-utils branch February 26, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver/none No version bump required.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants