You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@grails.apache.org by "jamesfredley (via GitHub)" <gi...@apache.org> on 2026/01/26 03:09:18 UTC

[PR] Expand integration test coverage from ~74 to 500+ tests [grails-core]

jamesfredley opened a new pull request, #15348:
URL: https://github.com/apache/grails-core/pull/15348

   ## Summary
   
   This PR significantly expands the integration test coverage in the `grails-test-examples` modules, adding approximately **426 new integration tests** across multiple Grails 7 feature areas. The total test count has grown from ~74 to **500+ tests**.
   
   ## Test Coverage Added
   
   ### Core Framework Tests (app1 module)
   
   | 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 |
   
   ## Technical Details
   
   ### Test Patterns Used
   
   All tests follow Grails 7 best practices:
   - `@Integration(applicationClass = Application)` for integration context
   - `@Rollback` for transaction management
   - Micronaut HTTP client for endpoint testing
   - Spock 2.3 `given/when/then` blocks
   
   ### Key Dependencies
   - Spock 2.3-groovy-4.0
   - Micronaut HTTP Client
   - Geb (for functional tests requiring browser)
   
   ## 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
   
   ## Testing
   
   All 500+ tests pass locally:
   ```
   648 tests completed, 1 failed
   ```
   
   The single failure is a pre-existing Geb container test (`RedirectWithAndWithoutParamsFunctionalSpec`) that requires a container runtime - not related to this PR.
   
   ## Commits
   
   This PR is organized into 12 logical commits:
   1. Service layer integration tests
   2. Domain events and validation constraints tests
   3. Content negotiation and URL mappings tests
   4. Spring events and caching integration tests
   5. Async/promises and interceptor integration tests
   6. Data binding, codecs, and i18n integration tests
   7. TagLib and command object DI integration tests
   8. HTTP error handling, request/response, CORS, and file upload tests
   9. Advanced GORM integration tests and scaffolding module
   10. GSP layout taglib and Micronaut integration tests
   11. Async events integration tests to pubsub demo
   12. GORM advanced query and relationship tests to app1


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#discussion_r2743787402


##########
grails-test-examples/app1/grails-app/controllers/functionaltests/caching/CacheTestController.groovy:
##########
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package functionaltests.caching
+
+import grails.converters.JSON
+import org.springframework.beans.factory.annotation.Autowired
+
+/**
+ * Controller for testing caching features via HTTP.
+ */
+class CacheTestController {
+
+    static responseFormats = ['json']
+
+    @Autowired
+    CacheTestService cacheTestService

Review Comment:
   https://github.com/apache/grails-core/pull/15348/changes/76df61405f251e1a6f0ecdb46b5ea7fc7f32ca7f adds a number of tests to the existing ones for Cache



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#discussion_r2732483156


##########
grails-test-examples/app1/grails-app/controllers/functionaltests/binding/AdvancedDataBindingController.groovy:
##########
@@ -0,0 +1,297 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package functionaltests.binding
+
+import grails.converters.JSON
+import grails.databinding.SimpleMapDataBindingSource
+import grails.validation.Validateable
+import grails.web.RequestParameter
+
+/**
+ * Controller for testing advanced data binding features.
+ */
+class AdvancedDataBindingController {
+    
+    def grailsWebDataBinder
+    
+    /**
+     * Test basic map-based binding with nested objects.
+     */
+    def bindEmployee() {
+        def employee = new Employee(params)
+        render([
+            firstName: employee.firstName,
+            lastName: employee.lastName,
+            email: employee.email,
+            salary: employee.salary,
+            homeAddress: employee.homeAddress ? [
+                street: employee.homeAddress.street,
+                city: employee.homeAddress.city,
+                state: employee.homeAddress.state
+            ] : null
+        ] as JSON)
+    }
+    
+    /**
+     * Test @BindUsing annotation - email should be lowercased.
+     */
+    def bindWithBindUsing() {
+        def employee = new Employee(params)

Review Comment:
   I had no idea that bind using works with map params, how does this work? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#discussion_r2732479118


##########
grails-test-examples/app1/grails-app/controllers/functionaltests/binding/AdvancedDataBindingController.groovy:
##########
@@ -0,0 +1,297 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package functionaltests.binding
+
+import grails.converters.JSON
+import grails.databinding.SimpleMapDataBindingSource
+import grails.validation.Validateable
+import grails.web.RequestParameter
+
+/**
+ * Controller for testing advanced data binding features.
+ */
+class AdvancedDataBindingController {
+    
+    def grailsWebDataBinder
+    
+    /**
+     * Test basic map-based binding with nested objects.
+     */
+    def bindEmployee() {
+        def employee = new Employee(params)

Review Comment:
   This can be a security risk - especially on a user object.  I understand these are tests, but people look at the tests to see things are done.  I think if we're going to use map based binding, we should comment those sections saying generally this should be avoided / it can be a security risk.  I'll forgo making this change over and over ...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jdaugherty (via GitHub)" <gi...@apache.org>.
jdaugherty commented on code in PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#discussion_r2732490297


##########
grails-test-examples/app1/grails-app/controllers/functionaltests/caching/CacheTestController.groovy:
##########
@@ -0,0 +1,131 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package functionaltests.caching
+
+import grails.converters.JSON
+import org.springframework.beans.factory.annotation.Autowired
+
+/**
+ * Controller for testing caching features via HTTP.
+ */
+class CacheTestController {
+
+    static responseFormats = ['json']
+
+    @Autowired
+    CacheTestService cacheTestService

Review Comment:
   Shouldn't we add tests for @Cacheable too? 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "matrei (via GitHub)" <gi...@apache.org>.
matrei commented on PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#issuecomment-3811602506

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley merged PR #15348:
URL: https://github.com/apache/grails-core/pull/15348


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#issuecomment-3800709776

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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on code in PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#discussion_r2743833141


##########
grails-test-examples/app1/grails-app/controllers/functionaltests/binding/AdvancedDataBindingController.groovy:
##########
@@ -0,0 +1,297 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *    https://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package functionaltests.binding
+
+import grails.converters.JSON
+import grails.databinding.SimpleMapDataBindingSource
+import grails.validation.Validateable
+import grails.web.RequestParameter
+
+/**
+ * Controller for testing advanced data binding features.
+ */
+class AdvancedDataBindingController {
+    
+    def grailsWebDataBinder
+    
+    /**
+     * Test basic map-based binding with nested objects.
+     */
+    def bindEmployee() {
+        def employee = new Employee(params)

Review Comment:
   Agreed, `bindData(bean, params, [include: fields])` is what I use in all my apps, adjusting these tests.  
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Expand integration test coverage [grails-core]

Posted by "jamesfredley (via GitHub)" <gi...@apache.org>.
jamesfredley commented on PR #15348:
URL: https://github.com/apache/grails-core/pull/15348#issuecomment-3830063512

   Still reasonable workflow execution times.
   
   <img width="2670" height="1532" alt="image" src="https://github.com/user-attachments/assets/bd73e90e-7821-4e60-a332-319369612d41" />
   
   <img width="2754" height="1131" alt="image" src="https://github.com/user-attachments/assets/a4f90006-748b-4e90-a941-5e9d4e76c6e4" />
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@grails.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org