Re: [JVM] How to run cuke test from executable jar

3,219 views
Skip to first unread message
Message has been deleted

Ayoseg

unread,
Dec 11, 2012, 12:12:31 AM12/11/12
to cu...@googlegroups.com
Any one willing to help???

On Monday, 10 December 2012 22:15:20 UTC, Ayoseg wrote:
Apologies if I have duplicated post

Please can someone suggest a link or and an example where a cucumber test has been started from an executable jar. I did try with java - jar JarfileName.jar

but I got  

Exception in thread "main" cucumber.runtime.CucumberException: No features found
at 

at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:47)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:
93)
at cucumber.runtime.Runtime.run(Runtime.java:81)
at cucumber.cli.Main.run(Main.java:20)
at cucumber.cli.Main.main(Main.java:12)

. Please give example on how to run these type of file from the CLI

aslak hellesoy

unread,
Dec 11, 2012, 6:06:55 AM12/11/12
to Cucumber Users
On Mon, Dec 10, 2012 at 10:15 PM, Ayoseg <seg...@hotmail.com> wrote:
Apologies if I have duplicated post

Please can someone suggest a link or and an example where a cucumber test has been started from an executable jar. I did try with java - jar JarfileName.jar


Have you packaged cucumber-jvm and your own classes and features inside that jar? Where are your feature files?
 
but I got  

Exception in thread "main" cucumber.runtime.CucumberException: No features found
at 

at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:47)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:
93)
at cucumber.runtime.Runtime.run(Runtime.java:81)
at cucumber.cli.Main.run(Main.java:20)
at cucumber.cli.Main.main(Main.java:12)

. Please give example on how to run these type of file from the CLI 

--
-- 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
 
 

Message has been deleted

Ayoseg

unread,
Dec 11, 2012, 8:17:46 AM12/11/12
to cu...@googlegroups.com
Yes I have packaged all classes into an executable jar file using maven

<plugin> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution> <id>package-jar-with-dependencies</id>
<phase>package</phase> 
<goals> 
<goal>single</goal> 
</goals>
<configuration> 
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs> 
<archive> 
<manifest>
<mainClass>cucumber.cli.Main</mainClass> 
</manifest>
</archive> 
</configuration> 
</execution> 
</executions>
 </plugin>


My feature files are in a package in scr/test/resources/uk/co/tel/oop/feature

My RunTest class is in scr/test/java/uk/co/tel/oop

My step definition classes are in   scr/test/java/uk/co/tel/oop/projectStepDef 

I can run the test from command line using Maven on dev box. However, there is no internet connection on the test execution server, only way for me to execute is to package the classes into a Jar file, and then transfer this binary and execute from there

aslak hellesoy

unread,
Dec 11, 2012, 8:34:58 AM12/11/12
to Cucumber Users
Try this to learn about command line options:

  java - jar JarfileName.jar --help

Then try this:

  java - jar JarfileName.jar classpath:uk/co/tel/oop/feature

That should load the features, and report all steps as undefined since you still haven't told cucumber where stepdefs are. 
Now try this:

  java - jar JarfileName.jar --glue classpath:uk/co/tel/oop classpath:uk/co/tel/oop/feature
 

My RunTest class is in scr/test/java/uk/co/tel/oop


I'm assuming this is a @RunWith(Cucumber.class) annotated class. Using JUnit to run cucumber is another way to run cucumber, you don't use that when using the CLI directly.

Hope this helps,

Aslak
 
My step definition classes are in   scr/test/java/uk/co/tel/oop/projectStepDef 

I can run the test from command line using Maven on dev box. However, there is no internet connection on the test execution server, only way for me to execute is to package the classes into a Jar file, and then transfer this binary and execute from there


On Monday, 10 December 2012 22:15:20 UTC, Ayoseg wrote:
Apologies if I have duplicated post

Please can someone suggest a link or and an example where a cucumber test has been started from an executable jar. I did try with java - jar JarfileName.jar

but I got  

Exception in thread "main" cucumber.runtime.CucumberException: No features found
at 

at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:47)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:
93)
at cucumber.runtime.Runtime.run(Runtime.java:81)
at cucumber.cli.Main.run(Main.java:20)
at cucumber.cli.Main.main(Main.java:12)

. Please give example on how to run these type of file from the CLI

Ayoseg

unread,
Dec 11, 2012, 10:35:37 AM12/11/12
to cu...@googlegroups.com
Hi, I have tried your suggestion and it didn't work

So I decided to investigate further and I found out I made a grave error - my source class were not included in Jar file when I extracted files from the jar

I know this is not a cucumber issue, but I applied the same Technic to package the jar as I had done on other project I had worked on in the past, the main and only difference is that I I don't have a main class in my project as I am using the main class from cucumber library (cucumber.cli.Main). So I need to added something else to my maven to copy the source files from my application path. But I am not having any luck with that

I am looking for answers on google, but haven't a suitable one that work for me. 

Aslak Hellesøy

unread,
Dec 11, 2012, 10:51:32 AM12/11/12
to cu...@googlegroups.com

On Tuesday, 11 December 2012 at 15:35, Ayoseg wrote:

Hi, I have tried your suggestion and it didn't work

So I decided to investigate further and I found out I made a grave error - my source class
What do you mean by "source class" and why does it have to be in the jar? 

Ayoseg

unread,
Dec 11, 2012, 12:38:50 PM12/11/12
to cu...@googlegroups.com
Sorry I meant to say files from my source folder directory. I need to the compiled classes and feature files in the jar file, do I not?

aslak hellesoy

unread,
Dec 11, 2012, 1:00:40 PM12/11/12
to Cucumber Users
On Tue, Dec 11, 2012 at 5:38 PM, Ayoseg <seg...@hotmail.com> wrote:
Sorry I meant to say files from my source folder directory. I need to the compiled classes and feature files in the jar file, do I not?


Ok I see what you mean.

Here is an example of how you can add additional resources (i.e. not in src/main/resources) to your jar:

Aslak 

Ayoseg

unread,
Dec 13, 2012, 12:00:55 PM12/13/12
to cu...@googlegroups.com
Thanks for the  pointer. It helped in packaging the classes together, however I do have a problem getting the features to run.

java -jar myProject-1.0.jar -classpath uk/co/mycomp/bcp/features cucumber.cli.Main

I am getting no main manifest attribute in my jar file. I guess I have to have a line written as cucumber.cli.Main in my Manifest.MF file. I do not have that line in the file

I have this in my pom

<execution>
                        <id>package-jar-with-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>

                        </goals>
                        <configuration>
                            <appendAssemblyId>false</appendAssemblyId>
                            <descriptorRefs>
                                <descriptorRef>jar-with-dependencies</descriptorRef>
                            </descriptorRefs>
                            <archive>
                                <manifest>
                                    <mainClass>cucumber.cli.Main</mainClass>
                                </manifest>
                            </archive>
                        </configuration>
                    </execution>

Ayoseg

unread,
Dec 13, 2012, 12:17:51 PM12/13/12
to cu...@googlegroups.com
Nevermind, I got it to work

by using

<transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>cucumber.cli.Main</mainClass>
                                </transformer>
  </transformers>

parker

unread,
Dec 3, 2013, 1:15:53 PM12/3/13
to cu...@googlegroups.com
Hey, so sorry to dig up this extremely old thread.. but i can't find anything else on the web about this issue.  I'm trying to run my cucumber tests from an executable .jar as well.  I'm not very good with advanced POM configs, but could anyone please explain to me where im supposed to use the code below, and how this will help solve the problem?  I need to be able to package my project along with all dependencies, and be able to send the files off to a remote host to run without needing maven / all my project files.

<transformers>                      
<transformer implementation="org.apache.
maven.plugins.shade.resource.ManifestResourceTransformer">
          <mainClass>cucumber.cli.Main</mainClass>
</transformer> 
</transformers>


Reply all
Reply to author
Forward
0 new messages