Skip to content

Raise test coverage: instrument context-tests and add tests#318

Merged
alexander-yevsyukov merged 9 commits into
masterfrom
raise-coverage
Jul 7, 2026
Merged

Raise test coverage: instrument context-tests and add tests#318
alexander-yevsyukov merged 9 commits into
masterfrom
raise-coverage

Conversation

@alexander-yevsyukov

Copy link
Copy Markdown
Collaborator

Summary

Raises JVM test coverage for the validation compiler. Production-code coverage
improves from 301 → 166 missed lines (−135, ~45%) and 104 → 68 missed
branches
, via a mix of a coverage-measurement fix and new tests.

What changed

Credit context-tests coverage (the main lever)

context-tests ran its in-process compilation tests (66 RangeReaction cases,
Min/Max, and the other reaction/option specs) without the Kover plugin,
so the coverage they produce for :context production classes was never
credited to the aggregated report — those classes showed large false gaps.

  • context-tests/build.gradle.kts now applies org.jetbrains.kotlinx.kover, so
    KoverConfig folds the module into the root rollup.
  • build.gradle.kts excludes the module's generated Protobuf test fixtures
    (io.spine.tools.validation.given.**) from the aggregated report. KoverConfig
    only excludes generated classes discovered under main source sets, not
    testFixtures, so without this the generated fixtures would flood the report.

This credits ~105 previously-uncounted production lines and ~34 branches with
no new tests
.

New tests

  • ValidationSdkSpec — the ValidationSdk artifact coordinates / compiler-plugin FQN.
  • ValidateOptionSpec (+ validate_option_spec.proto) — the previously
    untested (validate)-on-a-non-message-field error path.
  • DeprecatedOptionsSpec (+ deprecated_options_spec.proto) — the
    deprecation warnings for (is_required) and (if_invalid), captured via
    tapConsole.
  • ValidationGradlePluginSpec — applies the plugin to a ProjectBuilder
    project and verifies the extension registration, transitive plugin
    application, and the runtime dependency. Requires testImplementation(gradleKotlinDsl())
    because the transitively-applied Spine Compiler plugin references
    org.gradle.kotlin.dsl extensions.

Version + reports

  • version.gradle.kts bumped 2.0.0-SNAPSHOT.448.449 (also migrated the
    deprecated by extra(...) delegate to extra.set(...)).
  • docs/dependencies/{pom.xml,dependencies.md} regenerated — applying Kover to
    context-tests brings its JaCoCo-engine dependencies into the aggregated graph.

Follow-up (not in this PR)

While raising coverage, ValidatorGenerator / ApplyValidator
(java/.../generate/ValidatorGenerator.kt, ~49 lines) were found to be dead
code
— never instantiated anywhere; the nested-message validation they were
meant to generate is handled at runtime by ValidatorRegistry. They show as
100% uncovered because they are unreachable. Removal is a separate production
change needing its own review.

The remaining gaps are the SetOnceRenderer-style view-query renderers (not
populated under PipelineSetup), the gradle plugin's afterEvaluate/doFirst
paths (need a real build / TestKit), and non-actionable guards/throw-helpers.

Reviewer notes

  • Pre-PR gate ran green: clean build dokkaGenerate passed; spine-code-review,
    kotlin-engineer, and review-docs all returned APPROVE.
  • The Kover exclude only drops generated fixtures (given.**); no main source
    declares that package, so no production coverage is masked.

🤖 Generated with Claude Code

alexander-yevsyukov and others added 8 commits July 6, 2026 21:11
The `context-tests` module ran its in-process compilation tests without the
Kover plugin, so the coverage they produce for `:context` production classes
(66 `RangeReaction` cases, `Min`/`Max`, and the other reaction/option specs)
was never credited to the aggregated report. Those classes therefore showed
large false coverage gaps.

Apply the Kover plugin to `context-tests` so `KoverConfig` folds the module
into the root rollup, and exclude the module's generated Protobuf test
fixtures (the `io.spine.tools.validation.given` package) from the root report:
`KoverConfig` only excludes generated classes discovered under `main` source
sets, not `testFixtures`, so without this the generated fixtures would flood
the report. This credits ~105 previously-uncounted production lines and ~34
branches with no new tests.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add `ValidationSdkSpec`, covering the Maven coordinates and compiler-plugin
class name exposed by the `ValidationSdk` object.

Add `ValidateOptionSpec` (with the `ValidateOnNonMessageField` proto fixture),
covering the previously untested field-type check in `ValidateReaction` that
rejects the `(validate)` option on non-message fields.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Regenerated after `context-tests` began applying the Kover plugin, which
brings its JaCoCo-engine dependencies into the aggregated graph.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add `DeprecatedOptionsSpec` (with the `deprecated_options_spec.proto` fixtures),
driving the compiler pipeline against messages that use the deprecated
`(is_required)` oneof option and `(if_invalid)` field option, and asserting the
deprecation warnings emitted by `IsRequiredReaction` and `IfInvalidReaction`
via captured console output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add `ValidationGradlePluginSpec`, which applies the plugin to a `ProjectBuilder`
project and verifies the configuration it performs eagerly: registering the
`validation` extension, applying the Protobuf and Spine Compiler Gradle plugins,
and adding the validation runtime as an `implementation` dependency.

Applying the plugin in-process exercises the transitively-applied Spine Compiler
plugin, which references `org.gradle.kotlin.dsl` extensions and requires the
`JavaPluginExtension`; hence the `testImplementation(gradleKotlinDsl())`
dependency and the `java` plugin applied first in the test. The plugin's
`afterEvaluate` and per-task `doFirst` actions run only during a real build and
remain covered by the integration projects under `:tests`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Raises JVM test coverage and improves coverage accounting by ensuring :context-tests contributes to the aggregated Kover report (while excluding generated Protobuf test fixtures), and by adding targeted tests for the Validation Gradle plugin and option reactions.

Changes:

  • Apply Kover to :context-tests and exclude io.spine.tools.validation.given.** from aggregated coverage to avoid generated-fixture noise.
  • Add new compilation/Gradle-plugin tests covering (validate) misuse and deprecated-option warnings, plus Gradle plugin wiring expectations.
  • Bump snapshot version to 2.0.0-SNAPSHOT.449 and regenerate dependency reports.

Reviewed changes

Copilot reviewed 22 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
version.gradle.kts Bumps the published snapshot version.
build.gradle.kts Adds root Kover report filter to exclude generated test fixtures.
context-tests/build.gradle.kts Applies Kover so :context-tests coverage is included in aggregation.
context-tests/src/testFixtures/proto/spine/validation/validate_option_spec.proto Adds fixture for (validate) option misuse case.
context-tests/src/testFixtures/proto/spine/validation/deprecated_options_spec.proto Adds fixtures for deprecated option warning cases.
context-tests/src/test/kotlin/io/spine/tools/validation/ValidateOptionSpec.kt Adds compilation-failure test for (validate) on non-message fields.
context-tests/src/test/kotlin/io/spine/tools/validation/DeprecatedOptionsSpec.kt Adds tests asserting deprecation warnings are emitted.
gradle-plugin/src/test/kotlin/io/spine/tools/validation/gradle/ValidationSdkSpec.kt Adds tests for exposed artifact coordinates and compiler-plugin FQN.
gradle-plugin/src/test/kotlin/io/spine/tools/validation/gradle/ValidationGradlePluginSpec.kt Adds tests for plugin application behavior (extensions, plugins, deps).
gradle-plugin/build.gradle.kts Adds gradleKotlinDsl() to test runtime to support ProjectBuilder-based tests.
docs/dependencies/pom.xml Regenerates dependency POM with updated version and dependency graph changes.
docs/dependencies/dependencies.md Regenerates dependency/license report with updated version and new deps.
.agents/tasks/spine-task-group-constant.md Removes an obsolete agent task document.
.agents/tasks/gradle-caching-plan.md Removes an obsolete agent task document.
.agents/tasks/enforce-max-line-length.md Removes an obsolete agent task document.
.agents/tasks/cross-agent-skill-best-practices.md Removes an obsolete agent task document.
.agents/tasks/buildsrc-gradle-review-findings.md Removes an obsolete agent task document.
.agents/tasks/archive/validating-builder-validate.md Adds an archived task note document.
.agents/tasks/archive/setup-cross-tool-agent-instructions.md Removes an obsolete archived agent task document.
.agents/tasks/archive/raise-coverage.md Removes an obsolete archived agent task document.
.agents/tasks/archive/raise-coverage-kover-migration.md Removes an obsolete archived agent task document.
.agents/tasks/archive/prompt-caching-org.md Removes an obsolete archived agent task document.
.agents/tasks/archive/prohibit-automatic-commits.md Removes an obsolete archived agent task document.
.agents/tasks/archive/api-discovery.md Removes an obsolete archived agent task document.

Comment thread version.gradle.kts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 825282bad4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread version.gradle.kts
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.55%. Comparing base (ec8c202) to head (bd0a068).

Additional details and impacted files
@@             Coverage Diff              @@
##             master     #318      +/-   ##
============================================
+ Coverage     82.64%   90.55%   +7.90%     
- Complexity      332      363      +31     
============================================
  Files            82       85       +3     
  Lines          2040     2138      +98     
  Branches        161      161              
============================================
+ Hits           1686     1936     +250     
+ Misses          289      158     -131     
+ Partials         65       44      -21     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexander-yevsyukov alexander-yevsyukov moved this to 🏗 In progress in v2.0 Jul 6, 2026
The `version.gradle.kts` bump migrated the publishing-version declaration from
the deprecated `val validationVersion by extra(...)` delegate to
`extra.set("validationVersion", ...)`. `build-and-release.md` embedded that line
via `start/end="val validationVersion"`, so the anchor no longer matched and
`:docs:checkSamples` failed (`Panic: there is no line matching Pattern
val validationVersion`).

Re-anchor the embed on `validationVersion` — unique in the file and stable
across version bumps — and regenerate the embedded snippet via
`:docs:embedCode`. Addresses the review comments on #318.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alexander-yevsyukov

Copy link
Copy Markdown
Collaborator Author

Fixed in bd0a068.

The version bump migrated version.gradle.kts from val validationVersion by extra(...) to extra.set("validationVersion", ...), which removed the line that build-and-release.md embedded via start/end="val validationVersion".

Rather than keep a val form just for the anchor, I re-anchored the embed on validationVersion (unique in the file and stable across version bumps, so it won't need touching on future bumps) and regenerated the snippet with :docs:embedCode. :docs:checkSamples now passes locally.

@alexander-yevsyukov alexander-yevsyukov moved this from 🏗 In progress to In Review in v2.0 Jul 7, 2026
@alexander-yevsyukov alexander-yevsyukov merged commit 99aa75e into master Jul 7, 2026
12 checks passed
@alexander-yevsyukov alexander-yevsyukov deleted the raise-coverage branch July 7, 2026 13:06
@github-project-automation github-project-automation Bot moved this from In Review to ✅ Done in v2.0 Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

3 participants