Lab 5 — Tests + CI/CD

Summary — what this page covers Attendees generate an AI-written test suite for their Day 2 features, then add a GitHub Actions workflow that does both halves of the outcome: automated AI code review on PRs and AI-generated release notes on tag push — committed. Prioritize the testing half; CI YAML can be largely provided as reference.

Duration: 25 min · Deliverable: AI-generated tests passing + GitHub Actions AI review + release-notes job, committed

Part A — Generate tests (≈10 min)

Use Claude Code to generate an xUnit suite for AgentService — happy path, a multi-tool run, a tool error, and a CancellationToken path — using NSubstitute and the existing patterns in BookTracker.Tests. Then run the adversarial edge-case prompt (see Section 5) and add the cases it surfaces. Run dotnet test until green.

Part B — Integration tests with TestContainers (≈stretch)

dotnet add BookTracker.Tests package Testcontainers.MsSql
dotnet add BookTracker.Tests package Testcontainers.Qdrant

Write one integration test that exercises the real SQL Server + Qdrant stack via TestContainers — no mocks. Optional if you're short on time.

Part C — AI code review in GitHub Actions (≈8 min)

Add .github/workflows/ai-code-review.yml: on a PR, diff the change and run claude --no-interactive --model claude-haiku-4-5 to review for security / .NET issues / missing error handling / CLAUDE.md violations, then post the result as a PR comment. Frame this workflow as your reusable code-review skill — the same review you run locally with /code-review, now in CI (the Day 1 steering touchpoint).

Part D — AI-generated release notes (≈7 min)

Add a release-notes job triggered on tag push: collect commits since the previous tag, pipe them to claude --no-interactive (Haiku, to keep CI cheap), and produce notes grouped as What's New / Bug Fixes / Breaking Changes / Developer Notes, attached to the GitHub Release.

git log ${PREV_TAG}..HEAD --format="%H %s %b" > commits.txt

Checkpoint

  • AI-generated tests pass (dotnet test)
  • Edge-case tests added from the adversarial pass
  • CI workflow runs the AI code review on a PR
  • Tag push produces AI-generated release notes
  • (Stretch) one TestContainers integration test passes
  • Committed to your fork

Bonus — The Full CI/CD Pipeline

No time pressure. Extend the workflow into a complete pipeline:

  • Build/test gates — run dotnet build and dotnet test as required checks before merge.
  • A quality gate — have the AI review fail the build on critical findings, not just comment.
  • Skill-usage logging — add the PreToolUse skill-logging hook from Day 1 so you can see which skills your CI actually triggers.