test: JaCoCo coverage gate + raise coverage ~33% → ~85%#315
Conversation
The SDK had no coverage instrumentation. The existing SdkTest aborts at @BeforeAll without a live Firefox, so almost no logic was measured (~33% floor). This adds JaCoCo (prepare-agent + report + check) and a new mock/HTTP-based PercyLogicTest (43 tests) that covers the SDK logic without a browser, lifting non-driver line coverage to ~84.7% (the CI browser run reaches ~87.8%). Gate: jacoco:check bound to the test phase, LINE minimum 0.83 — the honest floor for the unit-testable logic. The remaining uncovered lines are live-WebDriver-only (the JS-execution/cookie body of snapshot(), changeWindowDimensionAndWait CDP/resize, processFrame iframe recovery, the responsive-capture sleep) and are exercised by SdkTest on the browser CI (MOZ_HEADLESS=1 npx percy exec -- mvn test). PercyLogicTest covers: createRegion variants, snapshot/screenshot dispatch + guards, web DOM post + automate session metadata + region element conversion, responsive width-config HTTP, readiness config + waitForReady disabled paths, getSerializedDOM (cookies, cross-origin iframe, readiness diagnostics), healthcheck branches, log, Environment, setClientInfo, DriverMetadata + Cache. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The new PercyLogicTest cases passed locally (no Percy CLI) but failed on CI where `percy exec` runs a live CLI: - screenshotReturnsNullWhenPercyDisabled relied on isPercyEnabled defaulting to false; under percy exec the healthcheck enables it. Force isPercyEnabled =false via reflection so the disabled-path assertion is deterministic. - resolveResponsiveTargetHeightHonoursFeatureFlag's no-minHeight branch read cliConfig.snapshot.minHeight (1024 on CI). Clear cliConfig so it falls back to currentHeight as intended. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #315 • Head: 4351a2d • Reviewers: stack:code-reviewer SummaryTest-only change that adds a JaCoCo line-coverage gate and a new JVM unit-test class to raise measured coverage from ~33% to ~85%. Review Table
Findings
Verdict: PASS |
…o gate Brings the deterministic (non-live-browser) suite to 742/747 = ~99.3% line coverage and sets the JaCoCo BUNDLE LINE floor to a green 0.94 so the Linux CI Test jobs pass with headroom for macOS<->Linux counting variance. New mock/HTTP-based coverage (no exclusions, no @generated, no pragmas): - PercyDriverPathTest: WebDriver/JavascriptExecutor/HttpServer-mocked tests for snapshot() cookie/responsive/exception paths, healthcheck, fetchPercyDOM, getResponsiveWidths, waitForReady timeout set/restore, resolveReadinessConfig, CORS-iframe / FatalIframe handling, captureResponsiveDom CDP + setSize fallback + resize-wait + non-numeric-sleep / null-resizeCount paths. - CacheTest: Cache default ctor; DriverMetadata TracedCommandExecutor unwrap (success + reflective-failure fallback). - PercyStepsTest + a behavior-preserving resolveCucumberVersion(Callable) seam in PercySteps so the version null/throw fallbacks are testable without a jar manifest; lazy-Percy, options-table regions and scopeOptions parsing. The five remaining uncovered Percy lines are behaviorally unreachable defensive branches (null x-percy-core-version header Apache HttpClient never yields, the ChromeDriver no-CDP reflection fallback, and a non-numeric width the widths-config parser cannot produce) and were not covered to avoid altering production behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude Code PR ReviewPR: #315 • Head: 22cdf05 • Reviewers: stack:code-reviewer SummaryRaises JaCoCo line coverage from ~33% to ~99% by adding mock-based unit tests (new Review Table
FindingsNo Critical or High findings. Two Low-severity, non-blocking observations:
Verdict: PASS — behavior-preserving testability seam plus comprehensive mock-based coverage; no Critical/High issues and no High-row failures. |
What & why
The SDK had no coverage instrumentation. Its existing
SdkTestaborts at@BeforeAllwithout a live Firefox, so almost none of the logic was actually measured (~33% floor). This adds JaCoCo + an 83% line gate and a new mock/HTTP-based test class that covers the SDK logic without a browser.Coverage: ~33% → 84.7% line (non-driver); ~87.8% on the browser CI
New
PercyLogicTest(43 tests, all mock/HTTP-based, JUnit5 + Mockito + in-process HttpServer) covers:createRegionvariants,snapshot/screenshotdispatch + guards, web DOM post + automate session-metadata + region-element conversion, responsive width-config HTTP,resolveReadinessConfig/waitForReadydisabled paths,getSerializedDOM(cookies, cross-origin iframe, readiness diagnostics),healthcheckbranches,log, fullEnvironment,setClientInfo,DriverMetadata+Cache.Gate
jacoco-maven-plugin(prepare-agent + report + check) bound to thetestphase; CI already runsMOZ_HEADLESS=1 npx percy exec -- mvn test, so the gate runs there.snapshot(),changeWindowDimensionAndWaitCDP/resize,processFrameiframe recovery, the responsive-capture sleep. These run viaSdkTeston the headless-Firefox CI.Verification
(Full browser suite verifies on the push/dispatch CI — this repo's Test workflow runs on push + workflow_dispatch.)
🤖 Generated with Claude Code