Skip to content

Migrate remaining XCTest tests to Swift Testing#260

Open
giginet wants to merge 5 commits into
mainfrom
migrate-more-remaining-tests
Open

Migrate remaining XCTest tests to Swift Testing#260
giginet wants to merge 5 commits into
mainfrom
migrate-more-remaining-tests

Conversation

@giginet

@giginet giginet commented Dec 31, 2025

Copy link
Copy Markdown
Owner

Motivation & Context

Continuing the migration from XCTest to Swift Testing framework. This PR completes the migration of remaining test files that were still using XCTest.

Description

  • Migrate CacheSystemTests, RunnerTests, and IntegrationTests to Swift Testing
  • Convert XCTestCase classes to @Suite(.serialized) structs
  • Replace XCTAssertEqual/XCTAssertTrue/XCTAssertFalse with #expect
  • Replace XCTSkipUnless with .enabled(if:) trait
  • Replace addTeardownBlock with defer
  • Refactor detectFrameworkType function to FrameworkTypeDetector.detect static method

giginet and others added 5 commits December 27, 2025 12:24
- Replace XCTestCase with @suite(.serialized) struct
- Add descriptive test descriptions using @test macro
- Use TemporaryDirectoryTrait for temp directory management
- Replace XCTAssertEqual/XCTAssertNil with #expect
- Replace do-catch with XCTFail with #expect(throws:)
- Modernize URL APIs (filePath, appending(components:))

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Convert the standalone function to a static method on an enum for better
namespace organization and discoverability.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Comment on lines -848 to -858
override func tearDownWithError() throws {
try removeIfExist(at: testPackagePath.appendingPathComponent(".build"))
try removeIfExist(at: frameworkOutputDir)
try super.tearDownWithError()
}

private func removeIfExist(at path: URL) throws {
if fileManager.fileExists(atPath: path.path) {
try self.fileManager.removeItem(at: path)
}
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think the cleanup should be kept.

Comment on lines +209 to 211
await #expect(throws: CacheSystem.Error.self) {
_ = try await cacheSystem.calculateCacheKey(of: cacheTarget)
XCTFail("A cache key should not be possible to calculate if the package is not in a repository.")
} catch let error as CacheSystem.Error {
XCTAssertEqual(error.errorDescription, "Repository version is not detected for \(descriptionPackage.name).")
} catch {
XCTFail("Wrong error type.")
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The test should validate the actual error description as before.

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