Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8892401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:59:19+00:00 2026-06-14T22:59:19+00:00

If I generate a contoller using the command create-controller Grails generates the contoller and

  • 0

If I generate a contoller using the command “create-controller” Grails generates the contoller and a unit test (using the template /src/templates/scaffolding/Test.groovy).

After changing bits of the template I now want to generate the unit tests anew but Grails won’t generate them. I tried:

  • "create-unit-test" but this will use the template /src/templates/testing/UnitTest.groovy
    and
    "create-integration-test" will use the template /src/templates/testing/Generic.groovy

So how can I generate unit test for controller using the Test.groovy template?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T22:59:20+00:00Added an answer on June 14, 2026 at 10:59 pm

    When creating artifacts or using scaffolding, Grails uses templates to create the domain classes, controllers, views, etc. The default templates are part of the Grails distribution for out of the box behaviour, but can be customized for project specific needs.

    Copies the the templates used by Grails during code generation to your project directory:

    $ grails install-templates
    
    src/templates/
    ├── artifacts
    │   ├── Tests.groovy
    │   ├── ...
    ├── scaffolding
    │   ├── Test.groovy
    │   ├── ...
    └── war
        └── web.xml
    

    The artifacts directory contains the templates used by the create-* commands.
    The scaffolding directory contains templates used by the generate-* commands.
    The war directory contains the web.xml template used to generate the deployment descriptor.

    So you need to edit:

    • src/templates/artifacts/Tests.groovy file, when execute grails create-unit-test or grails create-integration-test commands.

    • src/templates/scaffolding/Test.groovy when execute grails generate-all or grails
      generate-controller
      commands.

    In your case regenerate your controller test and overwrite only your test file:

    $ grails generate-controller com.arturoherrero.Post
    | Generating controller for domain class com.arturoherrero.Post
    > File /grails-app/controllers/com/arturoherrero/PostController.groovy already exists. Overwrite?[y,n,a] n
    > File /test/unit/com/arturoherrero/PostControllerTests.groovy already exists. Overwrite?[y,n,a] y
    | Finished generation for domain class com.arturoherrero.Post
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Running the command generates new rails projects: $ rails generate controller home index The
I need to test a controller, of action index (generated by the grails generate-all
I have just created a controller using the command: rails generate controller LegacyPlanCalculator index
I'm trying to generate a Controller usind the Scaffolding Template Controller with read/write actions
When I create a new controller in Visual Studio with MVC It generate automatically
When using scaffolding in Ruby on Rails to build my controller, the scaffold is
I'm using sproutcore, and I use sc-gen to generate a controller like this (this
Is there a way to generate a subset of methods in the controller using
I am using Rails v2.3.2 I generate a controller by: script/generate controller cars It
I'm building an app with Rails 2.3.4 and using script/generate controller home index to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.