Migrate Test Suite from XCTest to Swift Testing - #9
Merged
Conversation
…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.
…rove test case clarity
…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.
…x for improved clarity.
…new test suites and updated assertions
…ation and progress tracking
…up and repository mock methods for improved clarity and maintainability.
… eliminate unused test settings.
… references across multiple test files for consistency.
Contributor
There was a problem hiding this comment.
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.
…oving error handling and code clarity.
…nwrapping, enhancing code safety.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Migrates the test suite from XCTest to Swift Testing and improves organization and coverage.
Changes
Files migrated
All tests now use Swift Testing with improved organization and expanded coverage.