Skip to content

Add SDK test infrastructure#20

Merged
teesofttech merged 1 commit into
mainfrom
feature/10-test-infrastructure
Jun 13, 2026
Merged

Add SDK test infrastructure#20
teesofttech merged 1 commit into
mainfrom
feature/10-test-infrastructure

Conversation

@teesofttech

@teesofttech teesofttech commented Jun 13, 2026

Copy link
Copy Markdown
Owner

Summary

Adds reusable test infrastructure for upcoming endpoint PRs so request-building tests and opt-in integration tests stay consistent.

What changed

Validation

  • dotnet build Termii.SDK.sln --configuration Release --no-restore
  • dotnet test Termii.SDK.sln --configuration Release --no-build

Closes #10

Summary by CodeRabbit

  • Documentation

    • Added TERMII_TEST_PHONE_NUMBER environment variable documentation for integration tests
    • Updated API coverage status: error handling marked as implemented, test helpers now in progress
  • Tests

    • Added test HTTP message handler for mocking HTTP responses
    • Added test factory helper for creating configured clients
    • Refactored integration and unit tests to use new test infrastructure

@coderabbitai

coderabbitai Bot commented Jun 13, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This PR builds test infrastructure for the Termii SDK by introducing fake HTTP message handlers, request extensions, and an integration test environment configuration. Unit tests are refactored to use the new utilities, replacing inline mocking. Documentation is updated to track implementation progress and environment variable requirements.

Changes

Test Infrastructure Implementation

Layer / File(s) Summary
Integration test environment configuration
tests/Termii.IntegrationTests/IntegrationTestEnvironment.cs, tests/Termii.IntegrationTests/TermiiClientIntegrationTests.cs
New IntegrationTestEnvironment static class exposes TERMII_API_KEY, optional TERMII_BASE_URL, and TERMII_TEST_PHONE_NUMBER environment variables; provides HasCredentials flag and CreateOptions() factory. Integration test now gates execution on credentials and uses the factory instead of manual environment variable reading.
Fake HTTP test utilities
tests/Termii.Tests/Infrastructure/TestHttpMessageHandler.cs, tests/Termii.Tests/Infrastructure/TestRequestExtensions.cs, tests/Termii.Tests/Infrastructure/TestTermiiClientFactory.cs
TestHttpMessageHandler queues HTTP responses and records requests; TestRequestExtensions adds ReadJsonBodyAsync to parse request JSON bodies; TestTermiiClientFactory.Create() wires the handler into HttpClient and constructs TermiiClient with test options.
Unit test refactoring
tests/Termii.Tests/TermiiClientTests.cs
All unit tests migrated from inline RecordingHttpMessageHandler to TestHttpMessageHandler and TestTermiiClientFactory. JSON assertions now use ReadJsonBodyAsync on handler.LastRequest. Old RecordingHttpMessageHandler implementation removed.
Documentation and tracking updates
.gitignore, README.md, docs/API_COVERAGE.md
API coverage status updated to reflect error handling/validation as Implemented and test helpers as In progress. README documents TERMII_TEST_PHONE_NUMBER environment variable. macOS .DS_Store added to .gitignore.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 New test helpers hop into the SDK,
Mocking HTTP, making checks go quick.
Fake handlers queue and record the flow,
Unit tests refactored, now they all know!
Integration waits for credentials so true,
Test infrastructure—complete and brand new! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add SDK test infrastructure' directly and clearly summarizes the main objective of the pull request, which is to introduce test infrastructure components for the SDK.
Linked Issues check ✅ Passed All coding requirements from issue #10 are met: TestHttpMessageHandler for fake HTTP handling [#10], request assertion helpers via TestRequestExtensions [#10], TestTermiiClientFactory for consistent client setup [#10], IntegrationTestEnvironment for credential-gated live tests [#10], and documentation updates.
Out of Scope Changes check ✅ Passed All changes are within scope: test infrastructure components [#10], integration test updates, documentation of environment variables [#10], API coverage status updates tracking #6 and #10, and .gitignore addition for macOS files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/10-test-infrastructure

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@teesofttech
teesofttech marked this pull request as ready for review June 13, 2026 18:12
Copilot AI review requested due to automatic review settings June 13, 2026 18:12
@teesofttech
teesofttech merged commit ee5a006 into main Jun 13, 2026
2 of 4 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

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.

Add SDK test infrastructure with fake HTTP handlers and optional live tests

2 participants