Skip to content

Conversation

@jamesfredley
Copy link
Contributor

@jamesfredley jamesfredley commented Jan 26, 2026

Summary

This PR significantly expands the integration test coverage in the grails-test-examples modules, adding approximately 479 new integration tests across multiple Grails 7 feature areas.

Test Coverage Added

Core Framework Tests

Category Tests Description
Services 25 Service injection, transactions, scoping, Spring bean integration
Domain Events 37 GORM lifecycle events (beforeInsert, afterUpdate, etc.)
Constraints 20 Validation constraints (nullable, blank, size, email, custom validators)
Content Negotiation 21 Format handling via Accept headers, extensions, parameters
URL Mappings 20 Path variables, constraints, HTTP methods, redirects
Spring Events 19 ApplicationEvent publishing/listening, async events
Caching 20 @Cacheable, @CacheEvict, cache manager integration
Async/Promises 20 Promise.task, callbacks, PromiseList/Map, timeouts
Interceptors 20 Before/after phases, matching patterns, request blocking
Data Binding 20 Type coercion, nested objects, collections, dates
Codecs 15 HTML, URL, Base64, JavaScript, MD5, SHA encoding
i18n 17 Message resolution, locale switching, pluralization
TagLib 25 Form tags, iteration, conditionals, custom tags
Command Object DI 10 @Autowired services in command objects
Error Handling 23 HTTP status codes (400-503), JSON error responses
Request/Response 20 Headers, cookies, sessions, request info
CORS 16 Preflight requests, cross-origin scenarios
File Upload 15 Single/multiple files, validation, content processing
GORM Advanced 53 Criteria queries, HQL, dynamic finders, relationships

Additional Module Tests

Module Tests Description
gorm ~45 Criteria queries, cascade operations, data services, scaffolding
gsp-layout 15 GSP layout tags, g:layoutHead/Body/Title
micronaut 10 Micronaut bean integration, qualifiers
async-events-pubsub-demo 8 Publisher/subscriber patterns
scaffolding-fields (new) 30 Fields plugin CRUD, custom templates, validation

Files Changed

  • New Controllers: 20+ test controllers across feature areas
  • New Domains: 15+ domain classes for testing
  • New Services: 12+ services for integration testing
  • New Specs: 25+ Spock specification files
  • New Views: 50+ GSP views for TagLib testing
  • settings.gradle: Added scaffolding-fields module

- Add ServiceSpec with 25 tests covering service injection, transactions,
  scoping, and Spring bean integration
- Add TestService with transactional methods and conditional logic
- Add Counter domain class for service state testing
- Tests verify @transactional behavior, rollback scenarios, and
  service-to-service dependencies
- Add DomainEventsSpec with 37 tests for GORM event lifecycle
- Tests beforeInsert, afterInsert, beforeUpdate, afterUpdate,
  beforeDelete, afterDelete, and onLoad events
- Add ConstraintsSpec with tests for validation constraints
- Tests nullable, blank, size, range, email, URL, matches patterns
- Includes custom validator and shared constraints testing
- Add ContentNegotiationSpec with 21 tests for format handling
- Tests JSON, XML, HTML responses based on Accept headers
- Tests format parameter, extension-based negotiation
- Add UrlMappingsSpec with 20 tests for routing
- Tests path variables, constraints, HTTP methods, redirects
- Includes optional parameters and format extension support
- Add SpringEventsSpec with 19 tests for ApplicationEvent handling
- Tests synchronous and async event publishing/listening
- Tests event inheritance and multiple listeners
- Add CachingSpec with 20 tests for @Cacheable, @CacheEvict
- Tests cache hits/misses, eviction strategies, conditional caching
- Includes cache manager integration and TTL behavior
- Add AsyncPromisesSpec with 20 tests for Grails async features
- Tests Promise.task, Promise.onComplete/onError callbacks
- Tests PromiseList, PromiseMap, and timeout handling
- Add InterceptorSpec with 20 tests for controller interceptors
- Tests before/after/afterView interceptor phases
- Tests matching patterns, model modification, request blocking
- Add DataBindingSpec with 20 tests for request parameter binding
- Tests type coercion, nested objects, collections, dates
- Add CodecsSpec with 15 tests for encoding/decoding
- Tests HTML, URL, Base64, JavaScript, MD5, SHA codecs
- Add I18nSpec with 17 tests for internationalization
- Tests message resolution, locale switching, pluralization
- Includes message bundles for English, French, German
- Add TagLibSpec with 25 tests for GSP tag libraries
- Tests form tags, iteration tags, conditional tags, link tags
- Tests custom tag implementation and encoding
- Add CommandObjectDISpec with tests for dependency injection
- Tests @Autowired services in command objects
- Tests validation with injected dependencies
- Add ErrorHandlingSpec with 23 tests for HTTP error responses
- Tests all common HTTP status codes (400-503)
- Tests JSON error payloads and custom error headers
- Add RequestResponseSpec with 20 tests for HTTP handling
- Tests headers, cookies, sessions, request info
- Add CorsAdvancedSpec with 16 tests for CORS headers
- Tests preflight requests and cross-origin scenarios
- Add FileUploadSpec with 15 tests for multipart uploads
- Tests single/multiple files, validation, content processing
- Add GormCriteriaQueriesSpec with tests for criteria builder
- Add GormCascadeOperationsSpec for cascade save/delete behavior
- Add GormDataServicesSpec for GORM Data Services
- Add GormEventsSpec for domain event handling
- Add ValidationConstraintsSpec for constraint testing
- Add FieldsValidationSpec for form field validation
- Add ScaffoldingFunctionalSpec for scaffolded CRUD UI
- Add scaffolding-fields module for fields plugin testing
- Updates build.gradle with necessary dependencies
- Add GspTagLibSpec for GSP layout and tag integration
- Tests g:layoutHead, g:layoutBody, g:layoutTitle tags
- Add MicronautContextSpec for Micronaut bean integration
- Add MicronautQualifierSpec for qualifier-based injection
- Tests Micronaut HTTP client and bean scoping
- Add AsyncEventsSpec with tests for event-driven architecture
- Tests publisher/subscriber patterns with async execution
- Update existing services for better test isolation
- Enhance BookSubscriber for async event handling
- Add GormAdvancedSpec with 53 tests for GORM queries
- Tests criteria queries, HQL, dynamic finders
- Tests projections, aggregations, and pagination
- Tests domain relationships (one-to-many, many-to-many)
- Includes cascade operations and orphan removal testing
Copilot AI review requested due to automatic review settings January 26, 2026 03:09
Copy link
Contributor

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.

Pull request overview

This PR significantly expands integration test coverage for the Grails test examples, adding approximately 426 new integration tests across multiple Grails 7 feature areas, increasing the total test count from ~74 to 500+ tests.

Changes:

  • Added comprehensive integration tests for core Grails features including services, domain events, constraints, content negotiation, URL mappings, Spring events, caching, async operations, interceptors, data binding, codecs, i18n, TagLibs, and more
  • Implemented supporting infrastructure including new controllers, domain classes, services, and views to facilitate testing
  • Enhanced the gorm module with scaffolding tests, GORM data services, and field validation tests
  • Added test isolation improvements for async event testing with reset methods and relative assertions

Reviewed changes

Copilot reviewed 147 out of 202 changed files in this pull request and generated no comments.

Show a summary per file
File Description
gorm/src/integration-test/groovy/gorm/FieldsValidationSpec.groovy New Geb-based functional test spec for fields plugin validation error display
gorm/grails-app/views/*.gsp Standard error, index, and notFound GSP views for the gorm module
gorm/grails-app/services/gorm/BookDataService.groovy GORM data service demonstrating auto-generated CRUD and custom queries
gorm/grails-app/i18n/messages.properties Standard Grails validation and UI messages
gorm/grails-app/domain/gorm/*.groovy Enhanced Book and Author domain classes with relationships and constraints
gorm/grails-app/controllers/gorm/*.groovy Scaffolded controllers and URL mappings for Author and Book
gorm/build.gradle Changed scaffolding and fields dependencies from runtimeOnly to implementation
async-events-pubsub-demo/src/main/groovy/pubsub/demo/BookSubscriber.groovy Added thread-safe list and reset method for test isolation
async-events-pubsub-demo/src/integration-test/groovy/pubsub/demo/*.groovy Enhanced existing tests with setup/teardown and added new async events test spec
async-events-pubsub-demo/grails-app/services/pubsub/demo/TotalService.groovy Added reset method for clearing accumulated state
app1/src/main/groovy/functionaltests/springevents/*.groovy New event classes for Spring events testing
app1/grails-app/views/tagLibTest/*.gsp GSP views for TagLib integration testing
app1/grails-app/views/contentNegotiation/*.gsp GSP views for content negotiation testing
app1/grails-app/services/functionaltests//.groovy Services for testing DI, caching, async operations, and Spring events
app1/grails-app/i18n/messages*.properties Added custom i18n test messages for English, French, and German
app1/grails-app/domain/functionaltests//.groovy Domain classes for testing events, constraints, binding, and GORM queries
app1/grails-app/controllers/functionaltests//.groovy Controllers and interceptors for testing various Grails features

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jamesfredley jamesfredley self-assigned this Jan 26, 2026
@jamesfredley jamesfredley moved this to In Progress in Apache Grails Jan 26, 2026
@jamesfredley jamesfredley changed the title Expand integration test coverage from ~74 to 500+ tests Expand integration test coverage Jan 26, 2026
@jamesfredley jamesfredley marked this pull request as draft January 26, 2026 03:24
Add ASF license headers to 19 GSP view files that were missing them,
fixing the RAT audit failure in CI.
- UserSpec: Make test self-contained by creating test data in given block
  instead of relying on Bootstrap data that may not exist in test context
- FieldsValidationSpec: Use timestamp-based email for uniqueness and
  increase waitFor timeout for more reliable test execution
- ValidationFunctionalSpec: Use flexible waitFor conditions that handle
  scaffolded templates which may not have expected CSS error classes
- FieldsValidationSpec: Add /author/save and /book/save to expected URLs,
  use proper field accessors (titleField.value() instead of title =),
  fix property assignment syntax (name.value() instead of name =)
- CustomTemplatesSpec: Use correct field names (firstNameField, lastNameField,
  emailField) and add flexible URL checking for form submissions
- FieldTypesSpec: Remove invalid jQuery :contains() CSS selector, use
  standard CSS attribute selector instead
- PaginationSpec: Use dataTable from base ScaffoldListPage instead of
  undefined employeeTable/departmentTable
- ScaffoldCreatePage: Improve createButton selector to try multiple patterns
- EmployeePages/DepartmentPages: Add table aliases and make 'at' checks
  more flexible for title matching
@jamesfredley
Copy link
Contributor Author

Appears to have a small impact the the CI workflows, overall.

@jamesfredley jamesfredley added this to the grails:7.0.7 milestone Jan 26, 2026
@jamesfredley jamesfredley marked this pull request as ready for review January 26, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant