Verify ManagedCode.ClaudeCodeSharpSDK behavior against real Claude Code CLI contracts, with deterministic automated tests for both the core SDK and the optional Microsoft.Extensions.AI adapter.
- Primary: TUnit behavior tests in
ClaudeCodeSharpSDK.Tests - Optional CI matrix: cross-platform Claude Code CLI smoke verification (
.github/workflows/claude-cli-smoke.yml)
- Test observable behavior, not implementation details.
- Use fake process runners for narrow unit tests where behavior is easier to isolate; use the real installed
claudeCLI for smoke and authenticated integration coverage. - Treat
claudeas a prerequisite for smoke and authenticated integration runs and install it in CI/local setup before running those tests. - CI validates Claude Code CLI smoke behavior on Linux/macOS/Windows without requiring login: CLI must be discoverable and invokable.
- Cross-platform CI smoke also validates unauthenticated behavior in an isolated profile.
- Real integration runs must use an existing Claude Code CLI login/session; test harness does not use API key environment variables.
- Authenticated local integration tests use an explicit TUnit skip condition when no local Claude Code session is available; missing auth is reported as skipped, not silently passed.
- Real integration model selection may be overridden with
CLAUDE_TEST_MODEL; otherwise tests use the Claude Code default model discovered from local settings. - Cover error paths and cancellation paths.
- Keep protocol parser coverage for all supported event/item kinds.
- Treat
claude -p --output-format json|stream-jsonas the protocol source of truth for smoke and parser tests.
- build:
dotnet build ManagedCode.ClaudeCodeSharpSDK.slnx -c Release -warnaserror - test:
dotnet test --solution ManagedCode.ClaudeCodeSharpSDK.slnx -c Release - coverage:
dotnet test --solution ManagedCode.ClaudeCodeSharpSDK.slnx -c Release -- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml - claude smoke subset:
dotnet test --project ClaudeCodeSharpSDK.Tests/ClaudeCodeSharpSDK.Tests.csproj -c Release -- --treenode-filter "/*/*/*/ClaudeCli_Smoke_*" - ci/release non-auth full run:
dotnet test --solution ManagedCode.ClaudeCodeSharpSDK.slnx -c Release -- --treenode-filter "/*/*/*/*[RequiresClaudeAuth!=true]"
Smoke subset is an additional gate and does not replace full-solution test execution. The focused smoke pattern uses the ClaudeCli_Smoke_* method prefix.
TUnit on Microsoft Testing Platform does not support --filter; run focused tests with -- --treenode-filter "/*/*/<ClassName>/*".
- Client lifecycle and concurrency: ClaudeClientTests.cs
ClaudeClientAPI surface behavior: ClaudeClientTests.csClaudeThreadrun/stream/failure behavior: ClaudeThreadTests.cs- CLI arg/env/config behavior: ClaudeExecTests.cs
- CLI locator behavior: ClaudeCliLocatorTests.cs
- CLI metadata parsing behavior: ClaudeCliMetadataReaderTests.cs
- Cross-platform Claude Code CLI smoke behavior: ClaudeCliSmokeTests.cs
- Real Claude Code CLI integration behavior (local login required): RealClaudeIntegrationTests.cs
Microsoft.Extensions.AImapper and DI behavior: ClaudeCodeSharpSDK.Tests/MEAI- Protocol parser behavior: ThreadEventParserTests.cs
- Structured output schema behavior: StructuredOutputSchemaTests.cs