Skip to content

test: close the audit coverage gaps - #135

Open
MaxMichel2 wants to merge 1 commit into
feat/networkmock-tags-and-sortingfrom
test/networkmock-audit-gaps
Open

MaxMichel2 wants to merge 1 commit into
feat/networkmock-tags-and-sortingfrom
test/networkmock-audit-gaps

Conversation

@MaxMichel2

Copy link
Copy Markdown
Collaborator

Summary

Implements PR 11 from the NetworkMock backlog handoff: closes the remaining test-coverage gaps tracked in #91.

Per the handoff doc's instruction, I re-scoped each of #91's seven gaps against current code before writing anything — the issue predates the OpenAPI migration and references files/classes that no longer exist (NetworkMockEndpointScreen → OperationPickerPage, NetworkMockEndpointPreviewBottomSheet.kt → MockResponsePreviewPage.kt).

Already covered (verified, not duplicated)

Gap Status
Ambiguous host-match precedence MockConfigRepositoryTest's findMatchingMock picks the first spec that has a matching operation when hosts collide / falls through to the next spec...
Preview/diff bottom sheet MockResponsePreviewPageTest.kt (page) + DiffLineUtilsTest.kt (diff logic)
Response Content-Type/header assertions Closed by #127 (returnsMockResponse_withDefaultContentTypeHeader / _withDeclaredHeadersAndContentType)

Genuinely open — closed by this PR

  1. Delay precedence — existing test covered operation-override and spec-default fallback, but not the "neither declares one → null" case. Added one test to complete the chain.
  2. Real sample spec parsing (devview-networkmock-core, new RealSampleSpecTest, androidHostTest) — no test previously loaded the actual shipped specs (sample/network's sample-api.json, jsonplaceholder.json) through the real MockConfigRepository; every other test uses hand-built inline fixtures, so the shipped sample could silently drift out of sync with what the parser accepts. Reads the files directly off disk via a devview.sampleNetworkResourcesDir system property (computed once at Gradle configuration time via rootProject.file(...), so it doesn't depend on the JVM working directory) — deliberately not a compile-time dependency on sample:network, which would invert this module's place in the dependency graph.
  3. Query-parameter matching end-to-end through the Ktor plugin — RequestMatcherTest already covered matchesQueryParams in isolation, but NetworkMockPluginTest had no coverage through the actual interception path. KtorPluginTestData's shared spec gains a listUsers operation (?type=user, mirroring the real sample spec), and NetworkMockPluginTest gains a "Query parameter matching" region (3 tests: matches, wrong value falls through, missing param falls through).
  4. Sticky-header status-family grouping — OperationPickerPage already groups responses by StatusCodeFamily with a sticky header per group, but nothing asserted the header text or that responses land in distinct groups. NetworkMockOperationSheetTest's existing fixture already spans two families (2xx/4xx); one added test asserts both headers render.

Testing

  • MockConfigRepositoryTest: +1 test (delay precedence completion).
  • RealSampleSpecTest (new, androidHostTest): 4 tests — both real sample specs parse, and a representative operation's declared response files all load.
  • NetworkMockPluginTest: +3 tests (query-parameter matching region).
  • NetworkMockOperationSheetTest: +1 test (sticky-header grouping).
  • CHANGELOG.md documents this as a coverage-closing entry (no user-facing behavior change).

Verification run locally

  • :devview-networkmock-core:testAndroidHostTest (commonTest + androidHostTest, incl. new RealSampleSpecTest) — ✅
  • :devview-networkmock-ktor:testAndroidHostTest — ✅
  • :devview-networkmock:compileAndroidDeviceTest — ✅
  • detektFull — ✅
  • :konsist:test — ✅
  • :sample:androidApp:assembleDebug — ✅

Closes #91.

@MaxMichel2
MaxMichel2 force-pushed the test/networkmock-audit-gaps branch from d70f894 to e92f942 Compare September 23, 2026 16:33
@MaxMichel2 MaxMichel2 added this to the 0.2.0 milestone Sep 23, 2026
@MaxMichel2 MaxMichel2 self-assigned this Sep 23, 2026
@MaxMichel2
MaxMichel2 added this pull request to stack #130 September 23, 2026 16:36
@MaxMichel2
MaxMichel2 force-pushed the test/networkmock-audit-gaps branch from e92f942 to c3ad1b4 Compare September 23, 2026 18:56
@MaxMichel2
MaxMichel2 force-pushed the test/networkmock-audit-gaps branch from c3ad1b4 to bb816df Compare September 24, 2026 06:19
Re-scoped issue #91's gap list against current code before writing anything
(the issue predates the OpenAPI migration and named files/classes that no
longer exist) and found four of its seven gaps already closed by prior work:

- Delay precedence: covered except the "neither declares one -> null" case -
  extended with one more test (existing test already covers operation-level
  override and spec-default fallback).
- Ambiguous host-match precedence: already fully covered by
  MockConfigRepositoryTest's two "hosts collide" tests. No action.
- Preview/diff bottom sheet: already fully covered by
  MockResponsePreviewPageTest.kt (the page) and DiffLineUtilsTest.kt (the
  diff logic it drives). No action.
- Response Content-Type/header assertions: already closed by #127
  (returnsMockResponse_withDefaultContentTypeHeader /
  _withDeclaredHeadersAndContentType). No action.

Three gaps remained genuinely open:

- Real sample spec parsing: no test previously loaded the actual shipped
  sample specs (sample/network's sample-api.json, jsonplaceholder.json)
  through the real MockConfigRepository - every existing test uses hand-built
  inline fixtures, so the shipped sample could silently drift out of sync
  with what the parser accepts. New RealSampleSpecTest (androidHostTest,
  since java.io.File isn't available on Kotlin/Native and this is a plain JVM
  sanity check) reads them directly off disk via a Gradle-configured
  devview.sampleNetworkResourcesDir system property, computed once at
  configuration time from rootProject.file(...) so the test doesn't depend on
  the JVM working directory - deliberately not a compile-time dependency on
  the sample module, which would invert this module's place in the
  dependency graph.
- Query-parameter matching end-to-end through the Ktor plugin:
  RequestMatcherTest already covered matchesQueryParams in isolation, but
  NetworkMockPluginTest had no end-to-end coverage through the actual
  interception path. KtorPluginTestData's shared spec gains a listUsers
  operation (?type=user, mirroring the real sample spec's own listUsers) and
  NetworkMockPluginTest gains a "Query parameter matching" region: matches on
  the declared value, falls through to network on a different value or a
  missing param.
- Sticky-header status-family grouping: OperationPickerPage's response list
  already groups by StatusCodeFamily with a sticky header per group, but
  nothing asserted the header text itself or that responses actually land in
  distinct groups - NetworkMockOperationSheetTest's existing 200/404 fixture
  already spans two families, so one added test closes this by asserting
  both family headers render.

CHANGELOG.md documents this as a coverage-closing entry rather than a
user-facing change (nothing here alters library behavior).
@MaxMichel2
MaxMichel2 force-pushed the test/networkmock-audit-gaps branch from bb816df to 5fc6207 Compare September 24, 2026 15:41

This branch has not been deployed

No deployments
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