test: coverlet coverage gate + raise non-driver coverage 28% → 54%#451
test: coverlet coverage gate + raise non-driver coverage 28% → 54%#451AkashBrowserStack wants to merge 2 commits into
Conversation
The SDK had coverlet present but unwired (no gate). This enables coverlet (adds coverlet.msbuild) and a 53% line gate in `npm test`, and adds a mock/HTTP-based PercyLogicTest (56 tests) covering the non-driver logic. Coverage (non-driver, local): 27.66% -> 54.16% line. The CI run (`npm test` = percy exec + full suite incl. the live-Firefox tests, which pass on the browser CI) covers more; 53% is the honest floor for the deterministic non-driver logic. New tests cover (via RichardSzalay.MockHttp + the internal setCliConfig seam): GetOrigin, IsUnsupportedIframeSrc, JSON helpers, ResolveReadiness Config merge, min-height/responsive-target resolution, isResponsive SnapshotCapture branches, PayloadParser, CreateRegion variants, Enabled healthcheck branches + caching, GetPercyDOM, GetResponsiveWidths, Log. Uncovered = live-Firefox/WebDriver only (Snapshot/getSerializedDom/ ProcessFrame/WaitForReady/CaptureResponsiveDom/ChangeWindowDimension and PercySeleniumDriver's reflection-on-real-driver paths) — exercised by the existing UnitTests class on the browser CI. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #451 • Head: 5a680a0 • Reviewers: stack:code-reviewer SummaryTest/build-config-only PR: wires up a coverlet line-coverage gate ( Review Table
FindingsNo Critical or High findings.
Verdict: PASS |
pranavz28
left a comment
There was a problem hiding this comment.
+--------+--------+--------+--------+
| Module | Line | Branch | Method |
+--------+--------+--------+--------+
| Percy | 64.81% | 70.54% | 81.48% |
+--------+--------+--------+--------+
+---------+--------+--------+--------+
| | Line | Branch | Method |
+---------+--------+--------+--------+
| Total | 64.81% | 70.54% | 81.48% |
+---------+--------+--------+--------+
| Average | 64.81% | 70.54% | 81.48% |
+---------+--------+--------+--------+
| "private": true, | ||
| "scripts": { | ||
| "test": "percy exec --testing -- dotnet test" | ||
| "test": "percy exec --testing -- dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:ThresholdType=line /p:Threshold=53" |
There was a problem hiding this comment.
Threshold should be 100%
…ate floor 91 The driver-bound half of the SDK (Percy.Snapshot web flow, getSerializedDom, ProcessFrame CORS-iframe handling, WaitForReady, CaptureResponsiveDom + ChangeWindowDimension/CDP resize, the Screenshot automate flow, and the entire PercySeleniumDriver/PercyDriver reflection surface) was previously only reached by the live-Firefox UnitTests class on CI. This adds deterministic, in-process coverage for all of it WITHOUT a browser and WITHOUT any production changes. Seam (zero production edits): a concrete FakeWebDriver subclasses Selenium's abstract WebDriver and overrides ONLY the single protected virtual ExecuteAsync(command, parameters) chokepoint that every WebDriver command routes through. This drives the real, sealed public Selenium methods (ExecuteScript, ExecuteAsyncScript, FindElements, SwitchTo, Manage().Window/Cookies/Timeouts, Navigate().Refresh) through genuine Selenium decoding/element-materialisation code. @percy/cli HTTP stays mocked with RichardSzalay.MockHttp. NewSession echoes the requested firstMatch caps so the real Capabilities property — and PercySeleniumDriver's reflection over ReturnedCapabilities/HttpCommandExecutor — exercises the actual production paths. A FakeChromeWebDriver exposes ExecuteCdpCommand to drive the CDP resize branch. Local line coverage (deterministic non-live suite): 54.16% -> 96.29%. PercyDriver, PercySeleniumDriver, Cache and all Region/Options types are now 100%. Remaining uncovered Percy.cs lines are env-gated static-readonly branches (PERCY_LOGLEVEL=debug, PERCY_RESPONSIVE_CAPTURE_MIN_HEIGHT/RELOAD_PAGE), a real-ChromeDriver type check, and effectively-dead catch arms. Gate: green floor raised 53 -> 91 (Threshold/p:ThresholdType=line), ~5 points below the locally-achieved 96.29% for macOS<->Linux variance. CI runs the full npm test (live UnitTests included) on pull_request, so CI coverage is >= local. Verified the gate fails the build when coverage drops below 91. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #451 • Head: d548340 • Reviewers: stack:code-reviewer SummaryAdds a coverlet line-coverage gate ( Review Table
FindingsNo Critical, High, or Medium findings. Low / informational (non-blocking):
Verdict: PASS — test-only change with no production code touched; faithful Selenium fakes, strong happy/error/edge-path coverage to ~96% (above the 91 floor), serialized static-state handling, and a single well-scoped dev dependency. No High row failed and no Critical/High finding. |
What & why
coverlet was present but unwired (no gate). This enables it (adds
coverlet.msbuild) with a 53% line gate innpm test, and adds a mock/HTTP-based test class covering the non-driver logic.Coverage: 27.66% → 54.16% line (non-driver, local); higher on the browser CI
New
PercyLogicTest(56 tests, xunit + RichardSzalay.MockHttp + the internalsetCliConfigseam) covers:GetOrigin,IsUnsupportedIframeSrc, JSON helpers,ResolveReadinessConfigmerge, min-height/responsive-target resolution,isResponsiveSnapshotCapturebranches,PayloadParser,CreateRegionvariants,Enabledhealthcheck branches + caching,GetPercyDOM,GetResponsiveWidths,Log.Gate
npm testnow runsdotnet test /p:CollectCoverage=true /p:ThresholdType=line /p:Threshold=53(CI runs the full suite underpercy execwith Firefox, so coverage there is higher; 53% is the guaranteed floor).Snapshot/getSerializedDom/ProcessFrame/WaitForReady/CaptureResponsiveDom/ChangeWindowDimensionandPercySeleniumDriver's reflection-on-real-driver paths — exercised by the existingUnitTestsclass on the browser CI.Verification
(Full browser suite + gate verify on this PR's CI — Test runs on pull_request.)
🤖 Generated with Claude Code