Want to jump right in? I have zipped up a working project, with examples. You can download it here.
What’s that? You like using Cucumber and want to use it with your Java project but your company ecosystem is not hip to JRuby? Enter the cukes4duke project, which allows you to run cucumber with most JVM-based languages. I am focusing on running it with the Maven plugin. This tutorial assumes you have maven installed, and Java knowledge.
Before you start, you must run the following goal. It will install JRuby and the gems to your .m2 repository.
Next, create a feature file under the ‘features’ directory (at the root of your project).
features/example.feature:
Feature: Example of a feature file
As some aspiring cuke4duke user
I want an example of how it works
So that I can easily setup my project to use it
# This should pass
Scenario: A simple passing scenario
Given the letter 'A'
When I check the letter
Then the letter should be 'A'
Then, create a ‘step’ class under src/test/java/cukes:
src/test/java/cukes/CukeSteps.java:
package cukes;
import cuke4duke.annotation.I18n.EN.Given;
import cuke4duke.annotation.I18n.EN.Then;
import cuke4duke.annotation.I18n.EN.When;
import static org.junit.Assert.assertThat;
import static org.hamcrest.CoreMatchers.is;
public class CukeSteps {
private char theLetter;
@Given("^the letter '([A-Za-z])'$")
public void gimmeALetter(final char theLetter) {
this.theLetter = theLetter;
}
@When("^I check the letter(?:s)?$")
public void checkThem() {
// just a stub
}
@Then("^the letter should be '([A-Za-z])'$")
public void checkTheLetter(final char aLetter) {
assertThat(theLetter, is(aLetter));
}
}
Now, run that test using:
mvn integration-test
I have zipped up an example project with more example steps. It is located here.
This entry was posted on Monday, July 12th, 2010 and is filed under Lessons. You can follow any responses to this entry through RSS 2.0.
You can leave a response, or trackback from your own site.
Yes, I saw that. I too was very impressed by the RoR-Cucumber testing integration. I am definitely going to try out your jump start as soon as I get the need. I wonder if a Maven archetype could be created for this type of project?
used > mvn -Dcucumber.installGems=true cuke4duke:cucumber
Error:
[INFO] Error opening script file: C:/Documents and Settings/gnava13/.m2/reposito
ry/.jruby/bin/cuke4duke (The system cannot find the path specified)
>Needs JRUBY, download jruby-bin-1.6.0.RC1.zip from http://jruby.org/
add C:\wallett\cuke4duke\runtime\jruby-1.6.0.RC1 to path env
> still same error
> downloaded cuke4duke.04.3.. soucres
> created two new env variable GEM_HOME, GEM_PATH pointing to C:\wallett\cuke4duke\runtime\jruby-1.6.0.RC1
You should not need to install any jruby stuff. The command ‘mvn -Dcucumber.installGems=true cuke4duke:cucumber’ should take care of that for you. Download the zip I have provided and run the command.
I get the same error on a fresh install of maven 3.0.2 as I did on 2.0.9
C:\workspace\maven-cuke>mvn -Dcucumber.installGems=true cuke4duke:cucu
[INFO] Scanning for projects…
[INFO]
[INFO] —————————————————————
[INFO] Building maven-cuke 1.0-SNAPSHOT
[INFO] —————————————————————
[INFO]
[INFO] — cuke4duke-maven-plugin:0.4.3:cucumber (default-cli) @ maven
[INFO] jruby: No such file, directory, or command — gem
[INFO] Error opening script file: C:/Documents and Settings/Ronald.Nob
ository/.jruby/bin/cuke4duke (The system cannot find the path specifie
[INFO] —————————————————————
[INFO] BUILD FAILURE
[INFO] —————————————————————
[INFO] Total time: 20.383s
[INFO] Finished at: Tue Feb 15 16:42:00 GMT 2011
[INFO] Final Memory: 2M/15M
[INFO] —————————————————————
[ERROR] Failed to execute goal cuke4duke:cuke4duke-maven-plugin:0.4.3:
default-cli) on project maven-cuke: JRuby failed. Java returned: 1 ->
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with t
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/Mojo
xception
C:\workspace\maven-cuke>mvn -version
Apache Maven 3.0.2 (r1056850; 2011-01-09 00:58:10+0000)
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: “windows xp”, version: “5.1″, arch: “x86″, family: “windows”
First thing is that my .jruby folder is empty so its never going to find the cuke4duke gems there. It seems like it is trying to launch jruby and install the gems but there is an error saying no such file or command –gem in the output.
I have got jruby installed at c:\jruby-1.5.6\ and I successfully got the cuke4duke gems from that by running jgem cuke4duke. I have the bin on the path as well for jruby but I do not have a RUBY_HOME or equivalent set do I need to set a gem path or something?
Here is some select output from mvn.
[DEBUG] Setting environment variable: GEM_HOME=C:\Documents and Settings\Ronald.
Noble\.m2\repository\.jruby
[DEBUG] Setting environment variable: GEM_PATH=C:\Documents and Settings\Ronald.
Noble\.m2\repository\.jruby
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 6.734s
[INFO] Finished at: Tue Feb 15 17:10:38 GMT 2011
[INFO] Final Memory: 2M/15M
[INFO] ————————————————————————
[ERROR] Failed to execute goal cuke4duke:cuke4duke-maven-plugin:0.4.3:cucumber (
default-cli) on project maven-cuke: JRuby failed. Java returned: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal c
uke4duke:cuke4duke-maven-plugin:0.4.3:cucumber (default-cli) on project maven-cu
ke: JRuby failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoExecutionException: JRuby failed.
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:87)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
… 19 more
Caused by: Java returned: 1
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:111)
at cuke4duke.ant.JRubyTask.execute(JRubyTask.java:22)
at cuke4duke.ant.CucumberTask.execute(CucumberTask.java:15)
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:84)
… 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
You do not need JRuby installed for this to work. It sounds like what may be happening is that it is querying gems to see if cuke4duke is installed, which tells it yes. Then it assumes it will be at .m2/repository… Perhaps that query takes place before the GEM_HOME is set?
Try and uninstall the cuke4duke via gems and see what that gives you.
I don’t seem to be having any luck. Uninstalling JRuby gives me this stack trace in the link below. Seems like it doesn’t recognise gems as a command when using java -classpath etc…
Is JRUBY_HOME still set? Why don’t you unset it, remote the whole m2 cache directory (~/.m2) and try it again. I am not that familiar with this tool so I am not sure if it uses JRUBY_HOME or not. I see you have posted to the cucumber mailing list. Perhaps you’ll have some luck there.
I never set the JRUBY_HOME variable I only added the JRuby bin folder to my PATH. I might try and get someone else to follow the same instructions and see how it goes for them.
I’m hoping I can get this sorted shortly I’m starting to run out of ideas after 2 days lol. Got it on stackoverflow and the cuke groups see if anyone else has had similar issues. Other people at work say they have only had it working on linux with version 0.4.3 and needed to use 0.4.2 in windows. Hopefully I’ll get it sorted.
I have run this project with no problems on two different computers since you started with no issues. They are both Windows 7 though. I have no idea why that would matter.
I went home and tried this exact same thing on windows 7 with a completely fresh maven 3.0.2 worked first time. Now I need to understand why it was not passing on my work machine.
Thanks for all the help and the informative blog post.
To get it working on xp then download the 0.4.2 source and build it yourself. This way you get the JRuby 1.5.3 dependency and not the 1.5.6 which doesn’t seem to play nice with xp.
Jruby 1.5.6 works nicely. As a side note, no spaces in your directory names. I spent a day an a half trying to get this to work, when I moved the project to a folder with no spaces in the name, it worked like a charm.
I had the same problem. But when I moved my maven repository away from the default C:\Documents and settings\…. to a path without spaces then it works. (Move the repository and add a setting to point to the new location in your maven settings.xml)
I cant get it working on XP. I tried version 0.4.4, 0.4.3 and 0.4.2. I got the 0.4.4 working on 7 easy.
I’m using
Maven 2.2.1,
Spring,
Eclipse Helios.
Java version 1.6.0_11,
Java home : ‘D:\…\jdk-1.6.0\jre’
OS wp version 5.1
I got the same error as Ron in his stack trace :
‘Caused by: org.apache.maven.plugin.MojoExecutionException: JRuby failed.
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:87)….’ JRuby failed. Java returned: 1
I got only one sucessfull build in 20 tries. and it was with only the test.feature but after one success I couldn’t get it working again. unstable ?
I tried :
* with jRuby-1.6.2 installed and JRUBY_HOME set ‘D:\…\jruby-1.6.2′ (jruby -v works)
* with jruby 1.5.3 and 1.6.0.
* whithout jRuby installed and without JRUBI_HOME
* with java 1.5 and 1.6
I have no spaces in my directories names. (repository , project)
Ron can you provide me more details with your installation on xp? is it working now with 0.4.4? what do you have in your paths, what are the steps of your installation…
Hi again, I think I got it now.
Win Xp, cuke4duke 4.0.4, maven 2.2.1
- Delete all JRUBY_HOME, jruby installations.
- Get JDK 1.6, be sure to have it in the project library!, not only added in eclipse projects by default, you can unroll it to see the version in the project;)
- Get the pom.xml above or add the dependencies you need. Be sure to check the maven-compiler-plugin version to match 1.6 int the Pom: 1.6 1.6. or Change version to 4.0.4 for the pom above.
- Run mvn -Dcucumber.installGems=true cuke4duke:cucumber
there’re a LOT of xml elements that should be camelCase but are alllowercase in your example! E.g. pluginRepository, jvmArgs, etc; please fix that, it drove me crazy
set environment vars: GEM_PATH = GEM_HOME = D:\…path…\.m2\repository\.jruby
gem install gherkin
gem install jruby-jars
gem install json
gem install term-ansicolor
gem install builder
gem install diff-lcs
gem install cucumber-1.0.0
gem install cuke4duke –ignore-dependencies (by default, it installs cucumber-1.0.1, which has a bug, so I disabled dependencies so that cuke4duke would use cucumber-1.0.0)
I had the same problem about the JRuby failed. Java Returned: 1 error. I got around it by creating a features directory. I saw the message about no features directory, but didn’t think that was causing the JRuby error. I also got around the cucumber 1.0.1 problem by adding this under properties
1.0.0
And adding this under gems:
install cucumber –version ${cucumber.version}
I put my two lines above the cuke4duke lines, so it first installed cucumber gem (1.0.0), so when it went to install cuke4duke, it already had cucumber (1.0.0). I also had to move my project to a directory without any spaces.
Hi,
Thank you for posting this article, it helped a lot.
I have done BDD automation with SpecFlow for a .Net project. Now, I want to do the same for a java project using Cucumber.
1. Could you please tell me, how should I setup Cucumber with my project step-by-step?
2. What should be the exact folder structure with respect to ‘SRC’ folder (or how to define it)?
3. How to setup Cucumber for RAD? Any plugin required?
Thanks.
Kerry is a technical consultant, web enthusiast, and loving father of two boys. He has experience with a
wide variety of technologies across multiple platforms.
#1 by James at July 12th, 2010
| Quote
Hi Kerry,
Nice explanation of using Cuke4Duke.
I did a jump start project for those wanting to do the same, using Cucumber, Spring 3 and Selenium.
The jump start project is here: http://jamesladdcode.com/?p=316
Rgs, James.
#2 by kerry at July 12th, 2010
| Quote
Yes, I saw that. I too was very impressed by the RoR-Cucumber testing integration. I am definitely going to try out your jump start as soon as I get the need. I wonder if a Maven archetype could be created for this type of project?
#3 by Russ White at July 12th, 2010
| Quote
Good stuff man. Definitely something I am looking into.
I love the annotation driven BDD stuff.
Cheers!
Russ
#4 by Tobias W. at August 17th, 2010
| Quote
Cool. But you should edit the pom.xml and update cuke4duke.version to 0.3.2 as 0.3.1 is broken with Cucumber 0.8.5:
http://groups.google.com/group/cukes/browse_thread/thread/f20d5aa8a48bde01
Otherwise, great howto!
Thanks!
#5 by kerry at August 17th, 2010
| Quote
Good catch. Funny thing is, I am the one who brought up the regression on the mailing list.
http://groups.google.com/group/cukes/browse_thread/thread/f20d5aa8a48bde01/54d74e3f5af05a35
I’ll update the post.
#6 by Goutham Naval at January 18th, 2011
| Quote
Hi kerry,
We would like to use cuke4duke for our testing our java restful services.
I tried to get the install of the cuke4duke plugin and got stuck.
I am not familiar with ruby, but assumed setting GEM_HOME and adding jruby to the path would do..
following are the steps I did, please advise..
http://jamesladdcode.com/?p=316
downloaded maven-cuke4duke-jump-start (mvn prj)
M2_HOME C:\wallett\cuke4duke\runtime\apache-maven-2.2.1
set up M2_REPO variable in eclipse ..
> changed proxy setting for maven2
>C:\wallett\cuke4duke\workspace\maven-cuke4duke-jump-start
>mvn clean
>mvn eclipse:eclipse
>mvn compile
wrong version in pom.xml for cuke4duke.version
used 0.4.3
does not download, bring it in manually from http://cukes.info/maven/cuke4duke/cuke4duke/0.4.3/ to C:\Documents and
Settings\gnava13\.m2\repository\cuke4duke\cuke4duke.4.3
>mvn compile goal does nothing.
used > mvn -Dcucumber.installGems=true cuke4duke:cucumber
Error:
[INFO] Error opening script file: C:/Documents and Settings/gnava13/.m2/reposito
ry/.jruby/bin/cuke4duke (The system cannot find the path specified)
>Needs JRUBY, download jruby-bin-1.6.0.RC1.zip from http://jruby.org/
add C:\wallett\cuke4duke\runtime\jruby-1.6.0.RC1 to path env
> still same error
> downloaded cuke4duke.04.3.. soucres
> created two new env variable GEM_HOME, GEM_PATH pointing to C:\wallett\cuke4duke\runtime\jruby-1.6.0.RC1
> loosks like it needs Gems, http://docs.rubygems.org/read/chapter/3
> downloaded rubygems-1.4.2.zip
> unzip to C:\wallett\cuke4duke\runtime\rubygems-1.4.2
> changed GEM_HOME to point to C:\wallett\cuke4duke\runtime\rubygems-1.4.2 and set up GEM_HOME and path as well
> still same error
Kind Regards,
Goutham Naval.
#7 by kerry at January 18th, 2011
| Quote
You should not need to install any jruby stuff. The command ‘mvn -Dcucumber.installGems=true cuke4duke:cucumber’ should take care of that for you. Download the zip I have provided and run the command.
http://www.goodercode.com/resources/maven-cuke.zip
#8 by Goutham Naval at January 18th, 2011
| Quote
Hi Kerry,
Mvn tries to find 0.3.1 plugin to download and fails.. from these repo’s
central (http://repo1.maven.org/maven2),
codehaus (http://repository.codehaus.org),
cukes (http://cukes.info/maven)
Where can I find 0.3.1 version of the plugin?
Kind Regards,
Goutham Naval
#9 by kerry at January 18th, 2011
| Quote
Is there a reason you are looking for that particular version? Seems like they only have 0.4.3 in the cukes repository.
#10 by Goutham Naval at January 18th, 2011
| Quote
Hi Kerry,
Thanks for your reply. Either 0.4.3, or 0.3.1 will be fine.
The sample http://www.goodercode.com/resources/maven-cuke.zip
uses 0.3.1 and to run the sample, I need 0.3.1 version of the maven plugin. However the only version hosted @ http://cukes.info/maven is 0.4.3
Regards,
Goutham Naval.
#11 by kerry at January 18th, 2011
| Quote
On a fresh install of maven 3:
Changed version from 0.3.1 to 0.4.3
Ran ‘mvn -Dcucumber.installGems=true cuke4duke:cucumber’
Worked perfectly.
#12 by Goutham Naval at January 19th, 2011
| Quote
OK thank you for your help.
#13 by Ron at February 15th, 2011
| Quote
I extracted the project that you gave and have the same problems as Goutham.
Running windows xp I run
“mvn -Dcucumber.installGems=true cuke4duke:cucumber”
I get the same error on a fresh install of maven 3.0.2 as I did on 2.0.9
C:\workspace\maven-cuke>mvn -Dcucumber.installGems=true cuke4duke:cucu
[INFO] Scanning for projects…
[INFO]
[INFO] —————————————————————
[INFO] Building maven-cuke 1.0-SNAPSHOT
[INFO] —————————————————————
[INFO]
[INFO] — cuke4duke-maven-plugin:0.4.3:cucumber (default-cli) @ maven
[INFO] jruby: No such file, directory, or command — gem
[INFO] Error opening script file: C:/Documents and Settings/Ronald.Nob
ository/.jruby/bin/cuke4duke (The system cannot find the path specifie
[INFO] —————————————————————
[INFO] BUILD FAILURE
[INFO] —————————————————————
[INFO] Total time: 20.383s
[INFO] Finished at: Tue Feb 15 16:42:00 GMT 2011
[INFO] Final Memory: 2M/15M
[INFO] —————————————————————
[ERROR] Failed to execute goal cuke4duke:cuke4duke-maven-plugin:0.4.3:
default-cli) on project maven-cuke: JRuby failed. Java returned: 1 ->
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with t
ch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions,
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/Mojo
xception
C:\workspace\maven-cuke>mvn -version
Apache Maven 3.0.2 (r1056850; 2011-01-09 00:58:10+0000)
Java version: 1.6.0_21, vendor: Sun Microsystems Inc.
Java home: C:\Program Files\Java\jdk1.6.0_21\jre
Default locale: en_GB, platform encoding: Cp1252
OS name: “windows xp”, version: “5.1″, arch: “x86″, family: “windows”
#14 by kerry at February 15th, 2011
| Quote
Perhaps you should rerun with -X to see if you get a better error.
#15 by Ron at February 15th, 2011
| Quote
First thing is that my .jruby folder is empty so its never going to find the cuke4duke gems there. It seems like it is trying to launch jruby and install the gems but there is an error saying no such file or command –gem in the output.
I have got jruby installed at c:\jruby-1.5.6\ and I successfully got the cuke4duke gems from that by running jgem cuke4duke. I have the bin on the path as well for jruby but I do not have a RUBY_HOME or equivalent set do I need to set a gem path or something?
Here is some select output from mvn.
[DEBUG] Setting environment variable: GEM_HOME=C:\Documents and Settings\Ronald.
Noble\.m2\repository\.jruby
[DEBUG] Setting environment variable: GEM_PATH=C:\Documents and Settings\Ronald.
Noble\.m2\repository\.jruby
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 6.734s
[INFO] Finished at: Tue Feb 15 17:10:38 GMT 2011
[INFO] Final Memory: 2M/15M
[INFO] ————————————————————————
[ERROR] Failed to execute goal cuke4duke:cuke4duke-maven-plugin:0.4.3:cucumber (
default-cli) on project maven-cuke: JRuby failed. Java returned: 1 -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal c
uke4duke:cuke4duke-maven-plugin:0.4.3:cucumber (default-cli) on project maven-cu
ke: JRuby failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:217)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProje
ct(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBu
ild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(Lifecycl
eStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:319)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:534)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Laun
cher.java:290)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.jav
a:230)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(La
uncher.java:409)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:
352)
Caused by: org.apache.maven.plugin.MojoExecutionException: JRuby failed.
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:87)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(Default
BuildPluginManager.java:107)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor
.java:209)
… 19 more
Caused by: Java returned: 1
at org.apache.tools.ant.taskdefs.Java.execute(Java.java:111)
at cuke4duke.ant.JRubyTask.execute(JRubyTask.java:22)
at cuke4duke.ant.CucumberTask.execute(CucumberTask.java:15)
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:84)
… 21 more
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please rea
d the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionE
xception
#16 by kerry at February 15th, 2011
| Quote
You do not need JRuby installed for this to work. It sounds like what may be happening is that it is querying gems to see if cuke4duke is installed, which tells it yes. Then it assumes it will be at .m2/repository… Perhaps that query takes place before the GEM_HOME is set?
Try and uninstall the cuke4duke via gems and see what that gives you.
#17 by Ron at February 16th, 2011
| Quote
Hi, Thanks for you help by the way.
I don’t seem to be having any luck. Uninstalling JRuby gives me this stack trace in the link below. Seems like it doesn’t recognise gems as a command when using java -classpath etc…
http://pastebin.com/ny0fSpTw
I installed the cuke4duke gem to the right folder using JRuby exe download. This got me a bit further but now it crashes on the script on line 9
require ‘rubygems’
Here is the stack trace.
http://pastebin.com/3t20GaDT
I’ve tried this in both maven 2.0.9 and 3.0.2
#18 by kerry at February 16th, 2011
| Quote
Is JRUBY_HOME still set? Why don’t you unset it, remote the whole m2 cache directory (~/.m2) and try it again. I am not that familiar with this tool so I am not sure if it uses JRUBY_HOME or not. I see you have posted to the cucumber mailing list. Perhaps you’ll have some luck there.
#19 by Ron at February 16th, 2011
| Quote
I never set the JRUBY_HOME variable I only added the JRuby bin folder to my PATH. I might try and get someone else to follow the same instructions and see how it goes for them.
I’m hoping I can get this sorted shortly I’m starting to run out of ideas after 2 days lol. Got it on stackoverflow and the cuke groups see if anyone else has had similar issues. Other people at work say they have only had it working on linux with version 0.4.3 and needed to use 0.4.2 in windows. Hopefully I’ll get it sorted.
Thanks for all your help.
#20 by kerry at February 16th, 2011
| Quote
I have run this project with no problems on two different computers since you started with no issues. They are both Windows 7 though. I have no idea why that would matter.
#21 by Ron at February 16th, 2011
| Quote
I went home and tried this exact same thing on windows 7 with a completely fresh maven 3.0.2 worked first time. Now I need to understand why it was not passing on my work machine.
Thanks for all the help and the informative blog post.
#22 by Sridhar at February 17th, 2011
| Quote
I too have tried this on XP without success, but was successfull on Windows 7
Thank you
#23 by Ron at February 22nd, 2011
| Quote
To get it working on xp then download the 0.4.2 source and build it yourself. This way you get the JRuby 1.5.3 dependency and not the 1.5.6 which doesn’t seem to play nice with xp.
#24 by Lex Starwind at March 29th, 2011
| Quote
Jruby 1.5.6 works nicely. As a side note, no spaces in your directory names. I spent a day an a half trying to get this to work, when I moved the project to a folder with no spaces in the name, it worked like a charm.
#25 by Lasse at April 3rd, 2011
| Quote
I had the same problem. But when I moved my maven repository away from the default C:\Documents and settings\…. to a path without spaces then it works. (Move the repository and add a setting to point to the new location in your maven settings.xml)
#26 by Louis at June 7th, 2011
| Quote
Hi,
I cant get it working on XP. I tried version 0.4.4, 0.4.3 and 0.4.2. I got the 0.4.4 working on 7 easy.
I’m using
Maven 2.2.1,
Spring,
Eclipse Helios.
Java version 1.6.0_11,
Java home : ‘D:\…\jdk-1.6.0\jre’
OS wp version 5.1
I got the same error as Ron in his stack trace :
‘Caused by: org.apache.maven.plugin.MojoExecutionException: JRuby failed.
at cuke4duke.mojo.CucumberMojo.execute(CucumberMojo.java:87)….’ JRuby failed. Java returned: 1
I got only one sucessfull build in 20 tries. and it was with only the test.feature but after one success I couldn’t get it working again. unstable ?
I tried :
* with jRuby-1.6.2 installed and JRUBY_HOME set ‘D:\…\jruby-1.6.2′ (jruby -v works)
* with jruby 1.5.3 and 1.6.0.
* whithout jRuby installed and without JRUBI_HOME
* with java 1.5 and 1.6
I have no spaces in my directories names. (repository , project)
Ron can you provide me more details with your installation on xp? is it working now with 0.4.4? what do you have in your paths, what are the steps of your installation…
Thanks
#27 by Louis at June 8th, 2011
| Quote
Hi again, I think I got it now.
Win Xp, cuke4duke 4.0.4, maven 2.2.1
- Delete all JRUBY_HOME, jruby installations.
- Get JDK 1.6, be sure to have it in the project library!, not only added in eclipse projects by default, you can unroll it to see the version in the project;)
- Get the pom.xml above or add the dependencies you need. Be sure to check the maven-compiler-plugin version to match 1.6 int the Pom: 1.6 1.6. or Change version to 4.0.4 for the pom above.
- Run mvn -Dcucumber.installGems=true cuke4duke:cucumber
Thanks kerry anyway
#28 by kerry at June 8th, 2011
| Quote
Thanks for the update, hopefully this will help others out with the XP issues.
#29 by Bill at July 1st, 2011
| Quote
I found I needed
0.4.4
Also needed to get rid of spaces in the directory names – oddly it was messing with classes in a sibling dir tree before I did this. (Windows 7)
#30 by Bill at July 1st, 2011
| Quote
Your comment is awaiting moderation.
I found I needed
cuke4duke.version 0.4.4
Also needed to get rid of spaces in the directory names – oddly it was messing with classes in a sibling dir tree before I did this. (Windows 7)
#31 by Alan Franzoni at July 5th, 2011
| Quote
there’re a LOT of xml elements that should be camelCase but are alllowercase in your example! E.g. pluginRepository, jvmArgs, etc; please fix that, it drove me crazy
#32 by kerry at July 5th, 2011
| Quote
Interesting. What setup does that cause a problem on? Send me your pom and I will update it (kwilson at goodercode dot com).
#33 by Felipe at July 15th, 2011
| Quote
Hey, I got the zip project (maven-cuke) working on WinXP.
Here’s what I had to do (I also changed cuke4duke version to 0.4.4 on pom.xml):
download and add to PATH: jruby-bin-1.6.2.zip
env var: HTTP_PROXY | http://CHAVE:SENHA@inet-sys.petrobras.com.br:8080
set environment vars: GEM_PATH = GEM_HOME = D:\…path…\.m2\repository\.jruby
gem install gherkin
gem install jruby-jars
gem install json
gem install term-ansicolor
gem install builder
gem install diff-lcs
gem install cucumber-1.0.0
gem install cuke4duke –ignore-dependencies (by default, it installs cucumber-1.0.1, which has a bug, so I disabled dependencies so that cuke4duke would use cucumber-1.0.0)
Hope it helps someone else
#34 by Shawn McCarthy at July 15th, 2011
| Quote
I had the same problem about the JRuby failed. Java Returned: 1 error. I got around it by creating a features directory. I saw the message about no features directory, but didn’t think that was causing the JRuby error. I also got around the cucumber 1.0.1 problem by adding this under properties
1.0.0
And adding this under gems:
install cucumber –version ${cucumber.version}
I put my two lines above the cuke4duke lines, so it first installed cucumber gem (1.0.0), so when it went to install cuke4duke, it already had cucumber (1.0.0). I also had to move my project to a directory without any spaces.
#35 by Rishi Dashora at September 25th, 2012
| Quote
Hi,
Thank you for posting this article, it helped a lot.
I have done BDD automation with SpecFlow for a .Net project. Now, I want to do the same for a java project using Cucumber.
1. Could you please tell me, how should I setup Cucumber with my project step-by-step?
2. What should be the exact folder structure with respect to ‘SRC’ folder (or how to define it)?
3. How to setup Cucumber for RAD? Any plugin required?
Thanks.