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 806139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T00:11:50+00:00 2026-05-15T00:11:50+00:00

I have two testing questions. Both are probably easily answered. The first is that

  • 0

I have two testing questions. Both are probably easily answered. The first is that I wrote this unit test in Grails:

void testCount() {
    mockDomain(UserAccount)

    new UserAccount(firstName: "Ken").save()
    new UserAccount(firstName: "Bob").save()
    new UserAccount(firstName: "Dave").save()

    assertEquals(3, UserAccount.count())
}

For some reason, I get 0 returned back. Did I forget to do something?

EDIT: OH, I understand. The validation constraints were violated, so they didn’t store. Is there any way to get some feedback here? That’s a really crappy thing to have happen….

The second question is for those who use IDEA. What should I be running – IDEA’s junit tests, or grails targets? I have two options.

Also, why does IDEA say that my tests pass and it provides a green light even though the test above actually fails? This will really drive me nuts if I have to check the test reports in html every time I run my tests…..

Help?

  • 1 1 Answer
  • 2 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-15T00:11:51+00:00Added an answer on May 15, 2026 at 12:11 am

    I always do object.save(failOnError: true) in tests to avoid silent failures like this. This causes an exception to be thrown if validation fails. Even without a real database in a unit test, most of the constraints will be checked, although I prefer to use integration tests if I want to test complex relationships between domain objects.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically I have two main questions: What exactly should you unit test? How do
I have two classes that I am testing (let's call them ClassA and ClassB).
Let's say I have two Tables, Lunch and Dinner. I know that both contain
I've run into this problem with testing. Let's assume I have two models, User
We have two code bases for testing and production. The only differences between these
When I'm testing my simple geometric library, I usually have one or two methods
I have two application that need to talk to each other. App1 needs to
I have two classes generated by LINQ2SQL both from the same table so they
I have two questions about creating thread safe types in python, and one related
I have not used Junit before and have not done unit testing automatically. Scenario:

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.