Skip to content

Migrate Test Suite from XCTest to Swift Testing - #9

Merged
ibrahimcetin merged 56 commits into
mainfrom
migrate-swift-testing
Nov 27, 2025
Merged

Migrate Test Suite from XCTest to Swift Testing#9
ibrahimcetin merged 56 commits into
mainfrom
migrate-swift-testing

Conversation

@ibrahimcetin

Copy link
Copy Markdown
Owner

Migrates the test suite from XCTest to Swift Testing and improves organization and coverage.

Changes

  • Migration: Converted all test files from XCTest to Swift Testing (@suite, @test, #expect, #require)
  • Test organization: Grouped tests into logical suites with consistent naming
  • Test coverage: Added tests for missing functionality and edge cases across collections and repository operations
  • Helper functions: Updated mockCommit and mockFile to generate sequential names/content, preventing duplicate commit errors
  • Tags: Added a centralized tagging system for filtering and categorization

Files migrated

  • Collection tests: BranchCollection, ConfigCollection, IndexCollection, ReferenceCollection, RemoteCollection, StashCollection
  • Repository operation tests: Add, Commit, Reset, Restore, Revert, Log, Diff, Switch, Show
  • Model tests: Signature, OID
  • Object tests: Reorganized and deduplicated

All tests now use Swift Testing with improved organization and expanded coverage.

…y creation

This update introduces two new methods in SwiftGitXTest: mockRepository and mockDirectory. These methods generate unique repository and directory names based on the calling test's file and function, facilitating parallel test execution. The implementation includes parameters for file identification, function naming, and the option to create a bare repository or directory.
This update modifies the BranchCollectionTests to utilize the new Testing framework, replacing XCTest assertions with the new #expect syntax for improved readability and consistency. Additionally, a new suite for remote branch operations is introduced, enhancing the organization of tests related to branch functionalities.
This update modifies the mockCommit function to automatically generate a unique commit message based on the sequence of commits. It also ensures that a unique file is created if none is provided, improving the reliability of the mock commit process in tests.
…ling

This update introduces new tests for branch operations in BranchCollectionTests, including creating and renaming branches with a force flag to overwrite existing branches. Additionally, tests for listing all branches and iterating through both local and remote branches have been added. Error handling tests for non-existent branches and operations in a detached HEAD state are also included, enhancing the robustness of branch-related functionalities.
…eration

This update modifies the mockFile function to allow for optional parameters for file name and content. If not provided, the function generates a unique sequential name and content based on the number of existing files in the working directory, improving the flexibility and reliability of file creation in tests.
… execution during all tests. The test can be enabled if needed for specific scenarios.
…ry operations

This update reorganizes the IndexCollectionTests by creating distinct test suites for add operations, remove operations, subdirectory operations, modified files, error cases, edge cases, and mixed operations. The changes enhance test clarity and maintainability, ensuring better structure and readability in the testing framework.
This update modifies the ReferenceCollectionTests to adopt the new Testing framework, replacing XCTest assertions with the #expect syntax for improved readability. Additionally, the tests are organized into a suite for better structure, enhancing the clarity and maintainability of the test cases related to reference lookups and listings.
…new test suites for save, list, apply, pop, and drop operations. Enhanced error handling tests and added assertions for stash management scenarios.
…ds for initialization and shutdown. Enhanced error handling in shutdown without initialization test and improved naming conventions for clarity.
…est structure and readability. Updated assertions to #expect syntax and organized tests into suites for lookup, list, and create operations, improving clarity and maintainability.
This update introduces several new tests for the TagCollectionTests, including scenarios for creating annotated tags with messages and custom taggers, as well as handling tag overwrites and errors when creating existing tags. These additions enhance coverage and ensure robust error handling in tag operations.
… equality, default values, and raw conversion. This includes tests for various scenarios such as default date and timezone, equality checks, and round-trip conversion, enhancing test coverage and reliability of the Signature functionality.
…izing tests into suites for add, commit, reset, restore, log, and revert operations. Updated assertions to #expect syntax, enhancing clarity and maintainability of test cases.
…ty testing, including initialization, abbreviation, round-trip conversion, and zero OID checks.
…et operations in the RepositoryResetTests suite. This enhances clarity and maintainability of the test structure.
…g scenarios for restoring file content, handling added files, creating revert commits, and managing multiple file changes. Introduced error handling for conflicting working tree changes.
…ntent checks, improving test clarity and consistency.
… improve parameter naming and add suffix support for directory creation.
…up and repository mock methods for improved clarity and maintainability.
… references across multiple test files for consistency.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR migrates the test suite from XCTest to Swift Testing, modernizing the testing infrastructure and improving test organization and coverage. The migration includes conversion of assertions, test function naming, and the introduction of a centralized tagging system for test categorization.

  • Converted all test assertions from XCTest (XCTAssert*) to Swift Testing (#expect, #require)
  • Reorganized tests into logical suites with descriptive names and tags
  • Enhanced helper functions (mockCommit, mockFile, mockRepository) to generate sequential, unique content preventing test conflicts
  • Added comprehensive test coverage for edge cases and error scenarios

Reviewed changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
Tags.swift New file introducing centralized tagging system for test categorization
SwiftGitXTests.swift Migrated runtime tests to Swift Testing with improved test isolation using mockDirectory
RepositoryTests.swift Split into multiple focused test files, migrated assertions, improved helper functions
Repository*Tests.swift New organized test files for operations (Add, Commit, Clone, Reset, Restore, Revert, Log, Diff, Switch, Show, Status, Patch, Push, Fetch)
CollectionTests/* Migrated collection tests with expanded coverage for branches, config, index, references, remotes, stashes, and tags
ModelTests/* New comprehensive tests for Signature and OID models
SwiftGitX.xctestplan Removed as no longer needed with Swift Testing
PerformanceTests Removed (to be reimplemented with Swift Testing performance APIs)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Tests/SwiftGitXTests/RepositoryTests/RepositoryPropertyTests.swift
Comment thread Tests/SwiftGitXTests/RepositoryTests/RepositoryPropertyTests.swift
Comment thread Tests/SwiftGitXTests/RepositoryTests/RepositoryPropertyTests.swift
Comment thread Tests/SwiftGitXTests/CollectionTests/IndexCollectionTests.swift Outdated
Comment thread Tests/SwiftGitXTests/CollectionTests/IndexCollectionTests.swift Outdated
Comment thread Tests/SwiftGitXTests/SwiftGitXTests.swift
Comment thread Tests/SwiftGitXTests/CollectionTests/BranchCollectionTests.swift Outdated
Comment thread Tests/SwiftGitXTests/RepositoryTests/RepositoryDiffTests.swift
@ibrahimcetin
ibrahimcetin merged commit c76d4b4 into main Nov 27, 2025
1 check passed
@ibrahimcetin
ibrahimcetin deleted the migrate-swift-testing branch November 27, 2025 21:26
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