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.

Related Blog Posts
Natively Compiled Java on Google App Engine
Google App Engine is a platform-as-a-service product that is marketed as a way to get your applications into the cloud without necessarily knowing all of the infrastructure bits and pieces to do so. Google App […]
Building Better Data Visualization Experiences: Part 2 of 2
If you don't have a Ph.D. in data science, the raw data might be difficult to comprehend. This is where data visualization comes in.
Unleashing Feature Flags onto Kafka Consumers
Feature flags are a tool to strategically enable or disable functionality at runtime. They are often used to drive different user experiences but can also be useful in real-time data systems. In this post, we’ll […]
A security model for developers
Software security is more important than ever, but developing secure applications is more confusing than ever. TLS, mTLS, RBAC, SAML, OAUTH, OWASP, GDPR, SASL, RSA, JWT, cookie, attack vector, DDoS, firewall, VPN, security groups, exploit, […]