How to Run Groovy test cases with Groovy Jar

Assume that you have a groovy file (test.groovy) and you want to run it with Groovy jar. Follow the below steps to do it.

Here is the test.groovy file

//test.groovy
println "test"

Then download the groovy.jar, If you don’t have it.

curl -s -L -o groovy.jar \
       "http://central.maven.org/maven2/org/codehaus/groovy/groovy-all/1.8.1/groovy-all-1.8.1.jar"

Then run the test file with the below command.

  java -cp groovy.jar groovy.lang.GroovyShell test.groovy

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s