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

  • SEARCH
  • Home
  • 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 4271516
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:27:11+00:00 2026-05-21T07:27:11+00:00

It is usually more complicated to write unit tests due to having to deal

  • 0

It is usually more complicated to write unit tests due to having to deal with mock objects than integration tests in a large Grails project. This article even suggests we can even do away with unit tests altogether and write only integration tests which I tend to agree.

The only disadvantage I see is the speed of execution for integration test as compared to same unit test.

What are your thoughts about this from your actual experience working on a large scale Grails project?

If we write a unit test that tests exactly same method and also write integration test that also tests exactly same method, is this normal way of writing tests?

What you ended up with in terms of ratio of unit tests to integrations tests in actual large Grails project?

Have you successfully completed a large Grails project without writing any tests?

  • 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-05-21T07:27:11+00:00Added an answer on May 21, 2026 at 7:27 am

    I always write my tests as unit tests if possible. I do this because:

    • unit tests execute quicker
    • I prefer to test each component in isolation, rather than testing all the components integrated together, because this makes it easier to identify the source of an error
    • the unit testing environment is simpler (e.g. no Spring application context), so there are fewer potential sources of failure that are unrelated to the test being performed

    An example of where I would write an integration test is if I want to test a Spring bean that I’ve defined in resources.groovy. Although I could instantiate the class and test it directly, my test would then need to know the current implementation class of that bean (which might change).

    In the long-run I think it’s actually more complicated to write integration tests, because the cost of maintaining them over time is higher than unit tests. Groovy/Grails has excellent support for mocking/stubbing, so the cost of mocking dependencies in unit tests is relatively low. Here’s a real-world example from one of my unit tests where I:

    • mock the messageSource Spring bean that would normally only be available in an integration test
    • mock two command classes such that I can call the validate() method, inspect the .errors property, etc.

    class MyUnitTests extends GrailsUnitTestCase {
    
        MessageSource messageSource
    
        protected void setUp() {
    
            super.setUp()
            // mockForConstraintsTests is a method provided by GrailsUnitTestCase
            [Complex, CategoryCommand].each {mockForConstraintsTests(it)}
    
            // 'mockMessage' will be returned by every method call on messageSource
            messageSource = {Object[] args -> "mockMessage"} as MessageSource
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My map has several hundred markers within a city. Usually no more than a
I've used lex and yacc (more usually bison) in the past for various projects,
We are using Linq to SQL to read and write our domain objects to
More recently, I have been seeing questions with the tag webkit. Such questions usually
I'm using XSLT keys in many contexts. Usually, the keys used are more or
Usually when I'm creating indexes on tables, I generally guess what the Fill Factor
Usually Flash and Flex applications are embedded on in HTML using either a combination
Usually when I need to fork in C, I do something like this: pid_t
Usually when I build a site, I put all the CSS into one file,
Usually, we install VS.NET on our production server, to solve problems easily with our

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.