test: add VCR record/replay harness for integration tests#306
Merged
Conversation
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.
🔬 TestGlance✅ 212 passed across 1 job — 100.0% · ⏱️ 2.0s
🟡 build — details✅ 212 passed vs
📝 63 removed 🐌 1 slower test: Updated 2026-06-15T20:54:17.319Z |
…lay-harness # Conflicts: # .github/workflows/dotnet.yml
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.
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/livemodes 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 redactkey/signature, base64 bodies (covering JSON and binary GeoTIFF/photo), and match on method + redacted URL + normalized body; replay honors the cancellation token.BaseTestIntegrationbuilds a per-testGoogleMapsClientthrough 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 whenRUN_BILLABLE_TESTSis unset — never in replay.dotnet.yml): default push/PR build runs inreplay(no key, covers the whole suite); a new scheduled/dispatchlivejob drift-checks against real Google.VcrHarnessTests(record→replay, redaction, loud miss, cancellation, end-to-end throughGoogleMapsClient) 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 buildacross all TFMs: 0 warnings / 0 errors.dotnet formatclean on all changed files.VCR_MODE=record GOOGLE_API_KEY=<key> RUN_BILLABLE_TESTS=true dotnet test— and committed; until then those tests skip in replay.Checklist
dotnet formathas been run.dotnet testpasses locally (offline replay; live integration tests pending recorded cassettes).