Skip to content

Expand integration test coverage#15348

Merged
jamesfredley merged 9 commits into7.0.xfrom
test/expand-integration-test-coverage
Feb 1, 2026
Merged

Expand integration test coverage#15348
jamesfredley merged 9 commits into7.0.xfrom
test/expand-integration-test-coverage

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 1,066 new integration tests across multiple Grails 7 feature areas.

Test Coverage Summary

Category Tests Description
Async/Promises 20 Promise.task, callbacks, PromiseList/Map, timeouts
Caching 42 @Cacheable, @CacheEvict, cache manager integration
Codecs 24 HTML, URL, Base64, JavaScript, MD5, SHA encoding
Command Object DI 21 @Autowired services in command objects
Constraints 37 Validation constraints (nullable, blank, size, email, custom)
Content Negotiation 21 Format handling via Accept headers, extensions, parameters
CORS 16 Preflight requests, cross-origin scenarios
Data Binding 25 Type coercion, nested objects, collections, dates
Datasources 27 Multiple datasource isolation, CRUD operations, transactions
Domain Events 37 GORM lifecycle events (beforeInsert, afterUpdate, etc.)
Error Handling 8 HTTP status codes (400-503), JSON error responses
External Configuration 42 Environment detection, property source priority, type conversion
File Upload 15 Single/multiple files, validation, content processing
Flash/Chain/Forward 14 Flash scope, chain model, forward dispatch
GORM Advanced 53 Criteria queries, HQL, dynamic finders, relationships
GORM Cascade 16 Cascade save/delete, orphan removal, relationship management
GORM Criteria 41 Criteria builder queries, projections, aggregations
GORM Data Services 27 Abstract data services, query methods, transactions
GORM Events 20 Lifecycle hooks, audit fields, dirty checking
GORM Validation 49 Field validation, custom validators, constraint inheritance
GORM Where Queries 21 Batch operations, DetachedCriteria, complex conditions
GSP/Layout 38 GSP layout tags, g:layoutHead/Body/Title, Sitemesh
i18n 28 Message resolution, locale switching, pluralization
Interceptors 29 Before/after phases, matching patterns, namespace/method matching
Micronaut 16 Micronaut bean integration, qualifiers
Plugins 57 Plugin lifecycle, load ordering, dependencies, configuration
Pub/Sub Events 17 Publisher/subscriber patterns, async events
Request/Response 20 Headers, cookies, sessions, request info
Scaffolding 147 Fields plugin CRUD, custom templates, validation, pagination
Services 25 Service injection, transactions, scoping, Spring bean integration
Spring Events 19 ApplicationEvent publishing/listening, async events
TagLib 58 Form tags, iteration, conditionals, custom tags
Transactions 16 Propagation modes, rollback rules, programmatic transactions
URL Mappings 20 Path variables, constraints, HTTP methods, redirects

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
@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
@jdaugherty jdaugherty requested a review from matrei January 28, 2026 14:18
@matrei
Copy link
Contributor

matrei commented Jan 28, 2026

@jdaugherty This PR was so big so I created #15359 (from this PR branch) to give my thoughts.

@jdaugherty jdaugherty modified the milestones: grails:7.0.7, grails:7.0.8 Jan 29, 2026
@jamesfredley jamesfredley force-pushed the test/expand-integration-test-coverage branch 3 times, most recently from b50523e to 66322fc Compare January 30, 2026 21:40
jamesfredley and others added 8 commits January 31, 2026 00:06
…tures

Add 250+ new integration tests covering previously untested Grails features:

Services & Transactions:
- ServiceSpec with 25 tests for service injection, transactions, scoping

Domain Events & Validation:
- DomainEventsSpec with 37 tests for GORM event lifecycle
- ConstraintsSpec for validation constraints testing

Content Negotiation & URL Mappings:
- ContentNegotiationSpec with 21 tests for format handling
- UrlMappingsSpec with 20 tests for routing

Spring Events & Caching:
- SpringEventsSpec with 19 tests for ApplicationEvent handling
- CachingSpec with 20 tests for @Cacheable, @CacheEvict

Async/Promises & Interceptors:
- AsyncPromisesSpec with 20 tests for Grails async features
- InterceptorSpec with 20 tests for controller interceptors

Data Binding, Codecs & i18n:
- DataBindingSpec with 20 tests for request parameter binding
- CodecsSpec with 15 tests for encoding/decoding
- I18nSpec with 17 tests for internationalization

TagLib & Command Objects:
- TagLibSpec with 25 tests for GSP tag libraries
- CommandObjectDISpec for dependency injection in command objects

HTTP Handling:
- ErrorHandlingSpec with 23 tests for HTTP error responses
- RequestResponseSpec with 20 tests for HTTP handling
- CorsAdvancedSpec with 16 tests for CORS headers
- FileUploadSpec with 15 tests for multipart uploads

GORM Advanced:
- GormAdvancedSpec with 53 tests for criteria queries, HQL, relationships
- GormCriteriaQueriesSpec, GormCascadeOperationsSpec, GormDataServicesSpec

GSP Layout & Micronaut:
- GspTagLibSpec for GSP layout and tag integration
- MicronautContextSpec, MicronautQualifierSpec for Micronaut bean integration

Async Events:
- AsyncEventsSpec for event-driven architecture testing
- Add missing Apache License headers to 19 GSP view files
- Fix UserSpec to be self-contained with test data in given block
- Fix FieldsValidationSpec to use timestamp-based email for uniqueness
- Fix ValidationFunctionalSpec to handle scaffolded templates
- Fix functional test failures in gorm and scaffolding-fields modules
- Improve page object selectors for test stability
- Add waitFor assertions for asynchronous test operations
- Fix assertions to handle timing variations in CI environments
- Improve test stability for ValidationFunctionalSpec
- Improve test stability for RelationshipsFunctionalSpec
- Update controllers and services for better test isolation
- Various code quality improvements across test examples
Add AdvancedCachingService with 15 unit tests covering:
- Null value caching behavior
- Exception handling (exceptions not cached)
- Collection caching (List and Map)
- Custom key caching with closures
- Cache eviction scenarios

Also includes:
- AdvancedCachingController for HTTP endpoints
- AdvancedCachingIntegrationSpec for integration tests
- UrlMappings for new controller endpoints
Replace implicit mass assignment (new Domain(params)) with explicit
field binding using params.subMap() and class-level bindParams fields
across all grails-test-examples controllers and test specs.

This change ensures:
- Explicit control over which fields are bound
- Clear visibility of bindable fields in each controller
- Protection against unwanted parameter binding

Updated 12 files across app1, hibernate5, and mongodb examples.
…config, and plugins

Add 132 new integration tests covering previously untested Grails features:

Multiple Datasources (27 tests):
- DatasourceSwitchingSpec: Datasource isolation, CRUD ops, dynamic finders
- CrossDatasourceTransactionSpec: Chained and nested transactions

External Configuration (48 tests):
- EnvironmentConfigurationSpec: Environment detection, profile-specific config
- ConfigurationPrioritySpec: Property source priority, placeholder resolution

Plugin System (57 tests):
- PluginLifecycleSpec: Plugin registration, configuration, metadata
- PluginLoadOrderSpec: loadAfter declarations, plugin ordering
- PluginDependencySpec: Dependencies, configuration merging, bean registration
…verage

- Expand FieldsValidationSpec from 10 to 22 tests with proper validation
- Expand PaginationSpec from 14 to 26 tests covering sorting and pagination
- Expand ValidationFunctionalSpec from 20 to 33 tests for all constraint types
- Expand RelationshipsFunctionalSpec from 16 to 30 tests for relationships
- Remove all '// TODO: Not fully implemented' markers
- Add missing micronaut-http-client dependency to cache module
- Fix AdvancedDataBindingController to use bindData() for collections
Interceptor Advanced Matching (app1):
- Namespace-based matching, HTTP method matching, action exclusion patterns
- Multiple match rules with OR logic, combined criteria and ordering

GORM Where Query Advanced (gorm):
- Batch updateAll()/deleteAll() operations
- IN, NOT IN, LIKE, ILIKE operators
- DetachedCriteria reuse and composition
- Pagination with where queries

Flash/Chain/Forward (app1):
- Flash scope retention across redirects, flash.now for same-request
- chain() model accumulation, forward() same-request dispatch

Transaction Propagation (gorm):
- REQUIRES_NEW, MANDATORY, SUPPORTS propagation
- rollbackFor and noRollbackFor rules
- Programmatic withTransaction/withNewTransaction
- Restore FlashChainForwardSpec with cookie-enabled HTTP client
  (session cookies required for flash scope and chain model)
- Use proper JSON rendering in AdvancedCachingController
- Add UUID to list cache data for eviction verification
- Update AdvancedCachingServiceSpec to use startsWith for list assertions
- Simplify timing interceptor test to avoid async race condition
@jamesfredley jamesfredley force-pushed the test/expand-integration-test-coverage branch from 309347c to b1389e7 Compare January 31, 2026 05:08
Copy link
Contributor

@jdaugherty jdaugherty left a comment

Choose a reason for hiding this comment

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

@matrei reviewed this rather well in the other PR that's been merged into this branch. I'm ok with these so I say merge them.

@jamesfredley
Copy link
Contributor Author

Still reasonable workflow execution times.

image image

@jamesfredley jamesfredley merged commit ea770fc into 7.0.x Feb 1, 2026
31 checks passed
@jamesfredley jamesfredley deleted the test/expand-integration-test-coverage branch February 1, 2026 01:58
@github-project-automation github-project-automation bot moved this from In Progress to Done in Apache Grails Feb 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants