Jun 2, 2009

Running and Debugging Grails Integration Tests In Eclipse

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 ${string_prompt} -integration”
    VM Arguments: -Dgrails.home=${grails_home} -Dbase.dir=”${project_loc:<your project>}” -Dgrails.env=development -Xms512M -Xmx768M -XX:PermSize=64M -XX:MaxPermSize=128M
  • On Classpath tab:
    User Entries add your project
    User Entries add all $GROOVY_HOME/dist and $GROOVY_HOME/lib jar files (to be safe)
  • On Source tab add your Java Project for debugging purposes
  • On Environment tab you have to add a JAVA_HOME and GRAILS_HOME 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 <your project>/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.

About the Author

Torey Lomenda profile.

Torey Lomenda

VP - Solution Delivery

Torey has over 26 years of software development experience.  As VP of Solution Delivery he blends his skills as a solution architect and pragmatic hands-on technologist to deliver working software solutions. He enjoys collaborating with clients and team members to develop enterprise software systems that provide right-fit solutions for the business.

 

As an architect he has expertise working with key stakeholders to drive common understanding leading to structured solutions that meet business, technical, and operational objectives. He follows a practical approach to modeling systems, applications, components, data and the flows between them to frame solutions that are feasible to implement.

 

As a technologist he has a solid foundation in web and mobile, cloud native APIs, and enabling modern platforms with the help of AWS and Kafka technologies. He has led the development of many mission-critical, end-to-end applications using a diverse set of technologies and supports a pragmatic delivery approach leveraging agile methodologies

 

Expertise: iOS and Android development, Web technologies (HTML, CSS, JavaScript, Ionic/Angular, Vue.js), APIs and enterprise applications (Spring Boot, Kotlin, Node.js, SQL, NoSQL).

 

Practical Experience: Cloud infrastructure (AWS, Google) and container orchestration (Docker, Rancher, Kubernetes), messaging (RabbitMQ) and data streaming (Kafka)

 

Interests: Micro-services architecture, cloud-based platforms and services, native & hybrid mobile development

One thought on “Running and Debugging Grails Integration Tests In Eclipse

  1. Kit Plummer says:

    Hey. Thanks for this!

    One issue I had was in the VM arguments where you have:

    VM Arguments: -Dgrails.home=${grails_home} -Dbase.dir=”${project_loc:}” -Dgrails.env=development -Xms512M -Xmx768M -XX:PermSize=64M -XX:MaxPermSize=128M

    I had to remove the -Dbase.dir=”${project_loc}” bit because it was added it twice. Other than that – perfect. Thanks again.

  2. Edvinas says:

    Great post!

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Blog Posts
Up to Spec: JavaScript Numeric Separators
Let's take a look at the proposal to add Numeric Separators to the JavaScript specification.
Using Conftest to Validate Configuration Files
Conftest is a utility within the Open Policy Agent ecosystem that helps simplify writing validation tests against configuration files. In a previous blog post, I wrote about using the Open Policy Agent utility directly to […]
SwiftGen with Image & Color Asset Catalogs
You might remember back in 2015 when iOS 9 was introduced, and we were finally given a way to manage all of our assets in one place with Asset Catalogs. A few years later, support […]
Tracking Original URL Through Authentication
If you read my other post about refreshing AWS tokens, then you probably have a use case for keeping track of the original requested resource while the user goes through authentication so you can route […]