Skip to content

test: add VCR record/replay harness for integration tests#306

Merged
maximn merged 4 commits into
masterfrom
maximn/vcr-test-replay-harness
Jun 15, 2026
Merged

test: add VCR record/replay harness for integration tests#306
maximn merged 4 commits into
masterfrom
maximn/vcr-test-replay-harness

Conversation

@maximn

@maximn maximn commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Integration tests now serve committed cassettes by default (VCR_MODE=replay), so the suite runs offline, with no API key, and at no cost — making community PRs cheap and reliable; record/auto/live modes hit live Google to (re)record or drift-check. As part of this, [BillableTest] is repurposed to gate live execution only, so billable fixtures (Places, Aerial View, Solar) run for free from cassettes in replay.

Related issue

n/a

Changes

  • GoogleMapsApi.Test/Vcr/VcrDelegatingHandler + Cassette/RecordedInteraction/CassetteLocator + VcrMode. Cassettes redact key/signature, base64 bodies (covering JSON and binary GeoTIFF/photo), and match on method + redacted URL + normalized body; replay honors the cancellation token.
  • BaseTestIntegration builds a per-test GoogleMapsClient through the handler and returns a placeholder key in replay; a missing cassette file skips the test (TODO to record), while a missing entry in an existing cassette fails loudly (API drift).
  • [BillableTest] now skips only in live modes when RUN_BILLABLE_TESTS is unset — never in replay.
  • CI (dotnet.yml): default push/PR build runs in replay (no key, covers the whole suite); a new scheduled/dispatch live job drift-checks against real Google.
  • Hermetic VcrHarnessTests (record→replay, redaction, loud miss, cancellation, end-to-end through GoogleMapsClient) plus docs (.agents/testing.md, CONTRIBUTING.md, Cassettes/README.md).

Test plan

  • dotnet test (default replay) on net8.0 and net10.0: 201 passed / 62 skipped / 0 failed — integration tests skip cleanly until cassettes are recorded; 12 hermetic VCR self-tests pass.
  • dotnet build across all TFMs: 0 warnings / 0 errors. dotnet format clean on all changed files.
  • Follow-up required: integration cassettes must be recorded once with a real key — VCR_MODE=record GOOGLE_API_KEY=<key> RUN_BILLABLE_TESTS=true dotnet test — and committed; until then those tests skip in replay.

Checklist

  • dotnet format has been run.
  • dotnet test passes locally (offline replay; live integration tests pending recorded cassettes).
  • Multi-framework build passes (netstandard2.0, net8.0, net10.0).
  • XML documentation updated if public API surface changed (test-only change; no public API surface affected).

Integration tests now serve committed cassettes by default (VCR_MODE=replay),
so the suite runs offline, with no API key, and at no cost — making community
PRs cheap and reliable. Record/auto/live modes hit live Google to (re)record or
drift-check.

- Vcr/: VcrDelegatingHandler + Cassette + RecordedInteraction + CassetteLocator;
  cassettes redact key/signature, base64 bodies (JSON and binary), match on
  method + redacted URL + normalized body; replay honors cancellation.
- BaseTestIntegration builds a per-test client through the handler and returns a
  placeholder key in replay; a missing cassette file skips, a missing entry in an
  existing cassette fails loudly (API drift).
- Repurpose [BillableTest] to gate live execution only: it never skips in replay,
  so billable fixtures run for free from cassettes.
- CI runs the default push/PR build in replay (no key); a scheduled/dispatch job
  runs live to detect drift.
- Hermetic VcrHarnessTests cover record->replay, redaction, loud miss,
  cancellation, and an end-to-end pass through GoogleMapsClient.
@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown

🔬 TestGlance

✅ 212 passed across 1 job — 100.0% · ⏱️ 2.0s

Job Result Pass rate Duration Health
build 212/212 · 100.0% ↑ 2.0s → Report
🟡 build — details

✅ 212 passed
████████████████ 100.0%
⏱️ 2.0s
📈 Pass rate: 100.0% ↑ (+22.1%) · Duration: 2.0s → (+3ms, +0.1%) · Tests: 212 (-63)

vs master

Metric master PR Delta
Pass rate 95.8% 100.0% +4.2%
Duration 10.5s 2.0s -81.4%

📝 63 removed

🐌 1 slower test: GetUri_MissingApiKey_Throws (+393%)

📄 HTML Report


Updated 2026-06-15T20:54:17.319Z

@maximn maximn merged commit bae4879 into master Jun 15, 2026
7 checks passed
@maximn maximn deleted the maximn/vcr-test-replay-harness branch June 15, 2026 21:12
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.

1 participant