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
Performance Test Liquibase Update
When doing a liquibase update to a database if you’re having performance issues, it can be hard to find out which updates are causing problems. If you need to measure the time to apply each […]
TICK Stack Monitoring for the Non-Technical
TICK – Telegraf, Influx, Chronograf, and Kapacitor – is a method of monitoring your systems and applications. In this article, I discuss in non-technical terms what the difference is between TICK and Prometheus Grafana A […]
Design Systems, Part 1 • Introduction
Business leaders need a practical guide to plan and execute Design System Initiatives. The aim of this series is to be that guide. This installment introduces terms and definitions as a primer on Design Systems.
ML for Translating Dysarthria Speech (Pre-Part 1)
What is Dysarthria? Per the Mayo Clinic, Dysarthria occurs when the muscles you use for speech are weak or you have difficulty controlling them. Dysarthria often causes slurred or slow speech that can be difficult […]