[JVM] Best way to run from command line with Groovy glue?

692 views
Skip to first unread message

Mike Howells

unread,
May 11, 2013, 8:10:44 AM5/11/13
to cu...@googlegroups.com
We're successfully running Cucumber-JVM tests with Groovy glue in Jenkins using the @RunWith JUnit wrapper, but we have situations where people need to run the tests from the command line, e.g. because they're ssh logged into a remote system and doing a bunch of other stuff on the command line.

So we want to be able to copy the jar file for the glue code onto the remote system and run feature files from the command line, with results shown in the classic 'pretty' coloured text format.

What's the best way to run tests from the command line with just a jar of Groovy glue and some feature files?


Message has been deleted

Mike Howells

unread,
May 11, 2013, 8:20:32 AM5/11/13
to cu...@googlegroups.com
Executing the JUnit wrapper via Maven (mvn -Dtest=TestFeatures test) is one way of course, but it's pretty slow going through the Maven phases every time when you're iteratively trying out new scenario, and you get all that waffle output by Maven when you really just want to see the scenario steps.

Peter DoMySEO

unread,
May 13, 2013, 12:41:14 AM5/13/13
to cu...@googlegroups.com
Shell script containing required environment variables would do the job
java -cp "${LIB_DIR}/*" cucumber.api.cli.Main --glue ${GLUE_CODE} ${FEATURES_DIR} --format ....
Message has been deleted

Mike Howells

unread,
May 13, 2013, 1:41:26 AM5/13/13
to cu...@googlegroups.com
Okay, eventually worked out that this does work with Groovy glue but requires an enormous class path to pick up all the dependencies:

java -cp <lots-and-lots-of-jars> cucumber.api.cli.Main --glue classpath:com.mytest.cuke.glue path/to/features

Need to package all your glue code plus all dependencies into a single jar, e.g. using maven-shade-plugin.



On Saturday, 11 May 2013 22:10:44 UTC+10, Mike Howells wrote:

aslak hellesoy

unread,
May 13, 2013, 8:03:17 AM5/13/13
to Cucumber Users
On Mon, May 13, 2013 at 12:37 AM, Mike Howells <quan...@gmail.com> wrote:
Okay, eventually worked out that this does work with Groovy glue but requires an enormous class path to pick up all the dependencies:

Welcome to the JVM. That's why people use Ant/Maven/Ivy/Gradle/Buildr etc.
 

java -cp <lots-and-lots-of-jars> cucumber.api.cli.Main --glue classpath:com.mytest.cuke.glue path/to/features

Need to package all your glue code plus all dependencies into a single jar, e.g. using maven-shade-plugin.


On Saturday, 11 May 2013 22:10:44 UTC+10, Mike Howells wrote:
--
-- Rules --
 
1) Please prefix the subject with [Ruby], [JVM] or [JS].
2) Please use interleaved answers http://en.wikipedia.org/wiki/Posting_style#Interleaved_style
3) If you have a question, don't reply to an existing message. Start a new topic instead.
 
You received this message because you are subscribed to the Google Groups Cukes group. To post to this group, send email to cu...@googlegroups.com. To unsubscribe from this group, send email to cukes+un...@googlegroups.com. For more options, visit this group at https://groups.google.com/d/forum/cukes?hl=en
---
You received this message because you are subscribed to the Google Groups "Cukes" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cukes+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike Howells

unread,
May 16, 2013, 8:30:10 AM5/16/13
to cu...@googlegroups.com
Okay so that brings us back to the original question of how to easily run cucumber-jvm with groovy glue from the command line.

As I said earlier, we're using maven to build but it's slow and noisy (even with --quiet) if you just want to execute using ready-made glue. We're not going to use ant or gradle instead of maven.

So is creating an überjar with all dependencies the best/only way?

As

aslak hellesoy

unread,
May 16, 2013, 9:09:38 AM5/16/13
to cu...@googlegroups.com
I would create a wrapper shell script:

#/bin/sh
java -cp all:your:jars cucumber.cli.Main $@

Aslak 
As
Reply all
Reply to author
Forward
0 new messages