Grails console

Grails is becoming more widely used in our projects. Today I was looking one presentation about GORM and noticed that a guy used a very nice tool. It’s grails console which can be used to test your code very quickly.

The command to run is grails console
It opens the window where you can write groovy code related to your project.

Image Hosting

So I’ve written a small test code which create 20 objects:

20.times { i ->
    def goal = new com.test.Goal(label: "Goal $i", value: com.test.DietGoalsEnum.MaintainWaightAndToneUp)

com.itteco.freeformfitness.Goal.list().each {
  goal ->
    println("Found: $goal.label -> $goal.value");

And as a result I get not only the items I’ve saved but the saved items from grails-app/conf/BootStrap.groovy also.
Pretty sweet for quick testing.