Add comprehensive unit test suite with 94 tests and 85% code coverage#6
Open
Blackbaud-PaulGibson wants to merge 3 commits intomasterfrom
Open
Add comprehensive unit test suite with 94 tests and 85% code coverage#6Blackbaud-PaulGibson wants to merge 3 commits intomasterfrom
Blackbaud-PaulGibson wants to merge 3 commits intomasterfrom
Conversation
- Created xUnit test project with Moq for mocking external dependencies - Added comprehensive tests for all service classes: * AuthenticationService: OAuth token management and HTTP client configuration * DataStorageService: Token encryption/decryption and file storage operations * ConstituentsService: API client HTTP requests and query parameter handling * DataSyncService: Constituent data synchronization and error handling * SyncApp: Command line argument parsing and timer orchestration - Added tests for all model classes: * ListQueryParams: Query parameter validation and empty state checking * StorageData: Data serialization and property management * AppSettings: Configuration binding and validation - All tests mock external dependencies (HTTP clients, data protection, file I/O) - Tests are fully isolated with no external dependencies or real API calls - Achieved 85% line coverage (285/335 lines) and 85% branch coverage (51/60 branches) - Generated comprehensive HTML coverage report Co-Authored-By: Paul Gibson <paul.gibson@blackbaud.com>
Author
|
@devin-ai-integration restructure the folder hierarchy so that the skyapi-headless-data-sync.Tests project is at the same level as the main skyapi-headless-data-sync project. Under the root of the repo have a folder as the root for the main csproj and another folder for the test csproj so the two projects are peers. |
…tests/ - Moved all main project files (Models, Services, Program.cs, etc.) to src/ folder - Moved all test files from skyapi-headless-data-sync.Tests/ to tests/ folder - Updated project reference in test project to point to ../src/skyapi-headless-data-sync.csproj - Both projects are now peer folders at repository root level - All 94 tests still pass after restructuring - Addresses PR comment feedback from @Blackbaud-PaulGibson Co-Authored-By: Paul Gibson <paul.gibson@blackbaud.com>
- Removed 38 coverage report files from tests/CoverageReport/ directory - Added .gitignore entries for **/TestResults/ and **/CoverageReport/ - Coverage reports are generated artifacts and should not be committed - Reports can still be generated locally using: dotnet test --collect:'XPlat Code Coverage' - Follows .NET community best practices for test coverage in source control Addresses feedback from @Blackbaud-PaulGibson about coverage report best practices Co-Authored-By: Paul Gibson <paul.gibson@blackbaud.com>
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.
Add comprehensive unit test suite with 94 tests and 85% code coverage
Summary
This PR adds a complete unit test suite for the SKY API Headless Data Sync application using xUnit and Moq, achieving 85% line coverage and 85% branch coverage with 94 tests. Additionally, the folder structure has been restructured to move the main project files to a
src/folder and test files to atests/folder, making both projects peer directories at the repository root level. Coverage report artifacts have been removed from source control following .NET community best practices.Key Components Tested:
Structural Changes:
src/directorytests/directoryReview & Testing Checklist for Human
src/folder structure../src/skyapi-headless-data-sync.csprojreferencedotnet testand confirm no real API calls are made, no files created outside test directories, and no network dependenciesRecommended Test Plan:
cd src && dotnet buildcd tests && dotnet testdotnet test --collect:"XPlat Code Coverage"Diagram
%%{ init : { "theme" : "default" }}%% flowchart TD Root["Repository Root"]:::context OldStructure["Old: Files at root level"]:::context NewSrc["src/<br/>Main Project Files"]:::minor-edit NewTests["tests/<br/>Test Project Files"]:::major-edit AuthService["src/Services/<br/>AuthenticationService.cs"]:::minor-edit DataStorage["src/Services/<br/>DataStorageService.cs"]:::minor-edit ConsService["src/Services/SkyApi/<br/>ConstituentsService.cs"]:::minor-edit SyncService["src/Services/DataSync/<br/>DataSyncService.cs"]:::minor-edit SyncApp["src/SyncApp.cs"]:::minor-edit AuthTests["tests/Services/<br/>AuthenticationServiceTests.cs"]:::major-edit DataTests["tests/Services/<br/>DataStorageServiceTests.cs"]:::major-edit ConsTests["tests/Services/SkyApi/<br/>ConstituentsServiceTests.cs"]:::major-edit SyncTests["tests/Services/DataSync/<br/>DataSyncServiceTests.cs"]:::major-edit AppTests["tests/SyncAppTests.cs"]:::major-edit Coverage["Coverage: 85% Line<br/>85% Branch<br/>94 Tests"]:::major-edit GitIgnore[".gitignore<br/>Coverage exclusions"]:::major-edit Root --> NewSrc Root --> NewTests Root --> GitIgnore NewSrc --> AuthService NewSrc --> DataStorage NewSrc --> ConsService NewSrc --> SyncService NewSrc --> SyncApp NewTests --> AuthTests NewTests --> DataTests NewTests --> ConsTests NewTests --> SyncTests NewTests --> AppTests AuthTests -.tests.-> AuthService DataTests -.tests.-> DataStorage ConsTests -.tests.-> ConsService SyncTests -.tests.-> SyncService AppTests -.tests.-> SyncApp NewTests --> Coverage subgraph Legend L1["Major Edit"]:::major-edit L2["Minor Edit"]:::minor-edit L3["Context/No Edit"]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
src/folder structure.Link to Devin run: https://app.devin.ai/sessions/8804940a60164e04bf1b2a2f3b8431d1
Requested by: Paul Gibson (@Blackbaud-PaulGibson)