Torey Lomenda

This is a follow on to Eclipse Setup for Grails 1.1 Development. Although not ideal Eclipse integration, by setting up a Run Configuration for your Grails project in Eclipse, you will be able to run and debug Grails integration JUnit tests within Eclipse.  Here is how:

  • Open Run Configurations
  • Select Java Applications->New
  • On the Main tab: Select your Grails project Main class:  org.codehaus.groovy.grails.cli.support.GrailsStarter
  • On Arguments tab: Program args (Including the quotes):  “test-app ${stringprompt} -integration” VM Arguments: -Dgrails.home=${grailshome} -Dbase.dir=”${project_loc:}” -Dgrails.env=development -Xms512M -Xmx768M -XX:PermSize=64M -XX:MaxPermSize=128M
  • On Classpath tab: User Entries add your project User Entries add all $GROOVYHOME/dist and $GROOVYHOME/lib jar files (to be safe)
  • On Source tab add your Java Project for debugging purposes
  • On Environment tab you have to add a JAVAHOME and GRAILSHOME environment variable.
  • On Common tab Display in Run and Debug Favorites menus
  • Apply and Done

Try it out.  Let’s say you have integration tests for a controller called SomeController.  When you run this new run configuration, when prompted type in SomeController.  The results of test will be shown in the console and the test report will be generated in /test/reports (you will have to manually re-sync to refresh the reports.

Now try setting a breakpoint in a test within the integration test case for SomeController.  Now run the debug configuration version of the setup you did above.  Again, when prompted enter SomeController. Eclipse should stop at your breakpoint.  Now you can debug your integration test within Eclipse without having to manually setup a remote debugger.

Share this Post

Related Blog Posts

JVM

Eclipse Setup for Grails 1.1 Development

May 27th, 2009

Overall I have enjoyed the development experience with Grails and I am excited about its future. I am a heavy Eclipse user so along with a number of folks in the community I have been a bit disappointed with the support in my favorite IDE. However…

Torey Lomenda
JVM

Automated Integration Testing with HttpUnit and ServletUnit

April 3rd, 2009

One frequent hole in Test Driven Development (or any other comprehensive attempt to test) in Java web applications is the presentation layer. Especially when using an MVC pattern to separate the work from the display, the trend is to do that testing…

Object Partners
JVM

Unit Testing Grails in Eclipse

February 16th, 2009

For the past several weeks, I’ve been working on a Grails app in my spare time, and I’m really excited about the future of Grails.  However, I’ve been a bit disappointed in the tooling currently available.  Myself and many of my clients use Eclipse…

David Reines

About the author

Torey Lomenda

Chief Software Technologist

Torey is a Chief Technologist at Object Partners Inc. specializing in Mobile & Enterprise technologies with over 19 years of professional experience. Most recently he has led a number of iOS-related projects, applying his expertise in building HTML5 and Native Objective-C & Swift-based apps for iOS (iPad/iPhone). He has led the development of various mission-critical applications and supports a pragmatic delivery approach using various agile methodologies. During his career he has gained expertise with iOS, Java/JEE ecosystem and its related open source (ie: Spring-related, Tomcat), Groovy/Grails, JavaScript & technologies (ExtJS, AngularJS) to deliver rich internet applications (RIAs), and various commercial technologies (ie: IBM/Tivoli, Oracle, Tibco).