-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Tests: Convert RegistryClientTests to Swift Testing #8640
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Tests: Convert RegistryClientTests to Swift Testing #8640
Conversation
Continue the test conversion to Swift Testing - Tests/PackageRegisttryTests/RegistryClientTests.swift
2a9db12
to
f3ef031
Compare
@swift-ci test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for converting tests to Swift Testing. It's appreciated getting assistance with these.
I noticed some test are calling testDiagnostics(...)
, which has a call to XCFail
. We should use expectDiagnostics(...)
instead to avoid a test using a mix of Swift Test and XCTest calls.
@@ -267,22 +270,18 @@ final class RegistryClientTests: XCTestCase { | |||
task = Task { | |||
do { | |||
_ = try await registryClient.getPackageMetadata(package: identity) | |||
XCTFail("Task completed without being cancelled") | |||
Issue.record("Task completed without being cancelled") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: consider changing this do ... catch ...
block to something as following
#expect(throws: _Concurrency.CancellationError) {
try await registryClient.getPackageMetadata(package: identity)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, much nicer, thanks
@@ -1497,18 +1405,12 @@ final class RegistryClientTests: XCTestCase { | |||
customToolsVersion: .v5_3 | |||
) | |||
let parsedToolsVersion = try ToolsVersionParser.parse(utf8String: manifest) | |||
XCTAssertEqual(parsedToolsVersion, .v5_3) | |||
#expect(parsedToolsVersion == .v5_3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): this do
block, and the one before, are very similar and can be converted to a parameterized tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
) | ||
let parsedToolsVersion = try ToolsVersionParser.parse(utf8String: manifest) | ||
XCTAssertEqual(parsedToolsVersion, .v5_3) | ||
#expect(parsedToolsVersion == toolsVersion ?? .current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (non-blocking): In order to be more explicit, the value of the expected passed tools version can be passed in as the test data, instead of using `toolsVersion ?? .current)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This exercises that "nil" is interpreted as .current, so was deliberate
@@ -1906,18 +1755,11 @@ final class RegistryClientTests: XCTestCase { | |||
} | |||
|
|||
let parsedToolsVersion = try ToolsVersionParser.parse(utf8String: manifest) | |||
XCTAssertEqual(parsedToolsVersion, .v5_3) | |||
#expect(parsedToolsVersion == toolsVersion ?? .current) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (blocking): the testDiagnostics(...)
calls from a few lines before is XCTest-specific as it has an XCFail(...)
call. Use expectDiagnostic(...)
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@swift-ci test |
@swift-ci test windows |
@swift-ci please test windows |
Continue the test conversion to Swift Testing