Skip to content

Add grails-spock-test-tour v8 guide#499

Merged
jamesfredley merged 1 commit intomasterfrom
add-grails-spock-test-tour-v8
May 3, 2026
Merged

Add grails-spock-test-tour v8 guide#499
jamesfredley merged 1 commit intomasterfrom
add-grails-spock-test-tour-v8

Conversation

@jamesfredley
Copy link
Copy Markdown
Contributor

Summary

Adds the A Spock Test Tour for Grails 8 guide as the seventh Grails 8 sample-app-flavour guide. Following PRs #479, #493, #494, #495, #496, #497, #498.

Working examples of every Spock test layer Grails 8 supports, framed by which test type catches which class of bug. Replaces the oldest testing content on the portal (grails-controller-testing, grails-mock-basics, grails-test-domain-class-constraints, all from 2017).

Greenfield - no upstream rename

The new grails-guides/grails-spock-test-tour repository was created public with grails8 as its default branch. The four legacy single-topic test guides (grails-controller-testing, grails-mock-basics, grails-test-domain-class-constraints, grails-test-security) are intentionally left alone - they continue to resolve.

What's in the PR

  • conf/guides.yml - new grails-spock-test-tour registry entry, alphabetical insertion between grails-soap and grails-spring-security-core-plugin-custom-authentication.
  • guides/grails-spock-test-tour/v8/guide/*.adoc - 13 chapters, one per test layer plus framing material.
  • guides/grails-spock-test-tour/v8/snippets/ - vendored Book domain, BookService data service, BookController, plus four spec files (BookSpec, BookServiceSpec, BookControllerSpec, BookIntegrationSpec).

Test layers covered

Layer Spec file What it tests Speed
DomainUnitTest<Book> BookSpec Constraints, @Unroll where: table <100 ms
ServiceUnitTest + DataTest BookServiceSpec GORM finders against in-memory store <500 ms
ControllerUnitTest BookControllerSpec Action routing + response status <500 ms
@Integration + @Rollback BookIntegrationSpec Real Spring context, real datasource 5-20 s
Functional (Geb) (sketched in chapter, not vendored) Real booted app via browser 10-60 s

Upstream sample app

grails-guides/grails-spock-test-tour on the grails8 branch.

Verification

  • ./gradlew validateGuides -PvalidationMode=both returns 86 guides, 0 errors.
  • ./gradlew renderGuide_grails_spock_test_tour_8 --rerun-tasks --no-configuration-cache renders all 13 chapter HTML pages, no Unresolved directive errors.

Notes for reviewers

  • This is the seventh Grails 8 PR in the series and the third greenfield one (after Add grails-tailwindcss v8 guide #493 Tailwind and Add grails-htmx v8 guide #497 HTMX). The other four PRs renamed an existing legacy repo.
  • The where: data-table chapter forward-references the mock-call-count and block-discipline patterns rather than dedicating a chapter to each - they are mentioned briefly enough to stay actionable without ballooning the chapter count.
  • The functional-test chapter is intentionally a sketch (no vendored spec) because adding a working browser-driving Geb spec would require booting a real Postgres on the reader's machine. The chapter cross-references the CI/CD guide where that wiring is exercised on every push.

Working examples of every Spock test layer Grails 8 supports.
Greenfield - new grails-guides/grails-spock-test-tour repo created public
on the grails8 default branch.

The 13 chapters demonstrate one canonical example per layer:

- Getting Started (whatYouWillBuild, requirements, howto)
- Five Test Layers (the speed/cost/coverage matrix)
- DomainUnitTest for Constraints (BookSpec with @unroll where: table
  for pageCount)
- ServiceUnitTest + DataTest for Queries (BookServiceSpec, in-memory
  GORM, dynamic-finder testing)
- ControllerUnitTest for Routing (BookControllerSpec, response status +
  request.json shape)
- @Integration With @Rollback (BookIntegrationSpec, real Spring
  context, real datasource, transaction-isolated specs)
- Geb Functional Tests (Testcontainers Postgres, browser session reuse,
  cross-references the CI/CD guide for staging)
- Parameterised where: Data Tables (block discipline, mock-call-count
  assertions)
- useJUnitPlatform and JaCoCo Coverage (the wiring most teams get wrong)

Verified locally:

  ./gradlew validateGuides -PvalidationMode=both
    [validateGuides] mode=both: 86 guide(s) parsed, 0 SKIP-warned, 0 errors

  ./gradlew renderGuide_grails_spock_test_tour_8 --rerun-tasks --no-configuration-cache
    Renders all 13 chapter HTML pages, no Unresolved directive errors.

Assisted-by: claude-code:claude-opus-4-7
Copilot AI review requested due to automatic review settings May 3, 2026 20:15
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jamesfredley jamesfredley merged commit b5c0c07 into master May 3, 2026
5 checks passed
@jamesfredley jamesfredley deleted the add-grails-spock-test-tour-v8 branch May 3, 2026 22:48
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.

2 participants