To get sure if it are really 5, just print the count before the check
Main Topics
Browse All TopicsI'm working with Grails 1.1 and working through the book "Beginning Groovy and Grails from Novice to Professional".
First off - the author indicates that an integration test class will be automatically generated after the command to create a new domain class: create-domain-class todo. No such tests are created - the unit one gets created, not the integration test.
My real problem however, is when I create my own integration test class in the "test/integration" directory - and implement the test (see code).
Works fine UNTIL I attempt to add any additional properties to the "Todo.groovy" class other than "name".
So when it's simply;
class Todo {
}
The integration tests pass without issue. When I add something like;
class Todo {
String name
}
Tests still pass. BUT when I change the class to this;
class Todo {
String name
String note
}
The integration tests will not pass and don't provide any additional information other than the assertion failed;
Testcase: testPersist took 0.625 sec
Caused an ERROR
Expression: (5 == Todo.count())
java.lang.AssertionError: Expression: (5 == Todo.count())
at TodoIntegrationTests.testP
at _GrailsTest_groovy$_run_cl
at _GrailsTest_groovy$_run_cl
at _GrailsTest_groovy$_run_cl
at _GrailsTest_groovy$_run_cl
at TestApp$_run_closure1.doCa
at gant.Gant$_dispatch_closur
at gant.Gant$_dispatch_closur
at gant.Gant$_dispatch_closur
at gant.Gant.withBuildListene
at gant.Gant.this$2$withBuild
at gant.Gant$this$2$withBuild
at gant.Gant.dispatch(Gant.gr
at gant.Gant.this$2$dispatch(
at gant.Gant.invokeMethod(Gan
at gant.Gant.processTargets(G
at gant.Gant.processTargets(G
Any assistance would be greatly appreciated. Thanks in advance
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
See the tips section on this page (4th heading):
http://jan-so.blogspot.com
----------------
Tip: Saving domain object can fail without any error
Thanks for your participation - but I believe I have solved the problem;
Properties named in a class are required when saving, unless you declare it as "nullable" in the static constraints closure;
static constraints = {
note(nullable:true)
}
The "note" property of my Todo class is what was causing my problem - because in the integration test I was not passing a value for that property into the Todo constructor AND did not declare it as nullable in the class.
Business Accounts
Answer for Membership
by: TimYatesPosted on 2009-04-20 at 23:23:03ID: 24191332
Looks like it's failing as there aren't 5 of the Todo objects saved
Do you have constraints on the Todo class that could be stopping it getting saved?