How to use Cucumber with Java and Ant:

1. First download the JRuby from link http://www.jruby.org/download and install it.

 

After installation by default its path is set in environment variable if path is not set

 

first set the path.

 

Checkjruby –v on command prompt. If it is successfully installed the print a message

 

 

 

like jruby 1.4.0 (ruby 1.8.7 patchlevel 174) (2009-11-02 69fbfa3)

 

 

 

( Java HotSpot(TM) Client VM 1.6.0) [i386-java].

 

2. In next step download the Apache-ivy from link http://ant.apache.org/ivy/features.html and puts its jar ivy-2.2.0 file into Ant directory apache-ant-1.7.1\lib.

 

3. Create a project and put into 3 file.

 

·build.xml.

 

·ivy.xml.

 

·ivysettings.xml.

 

Build.xml:

 

 

default=”cucumber” basedir=”.”>

 

 

 

 

 

 

 

 

 

 

 

classpathref=”compile.classpath” encoding=”UTF-8″/>

 

 

 

 

 

 

description=”Run Cucumber”>

 

 

 

 

classpathref=”compile.classpath”/>

 

 

 

args=”–verbose –require target/test-classes –color

 

–format pretty –format junit

 

–out target/junit-report features”

 

objectFactory=”pico”>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

classpathref=”compile.classpath”/>

 

–source http://gemcutter.org/”/>

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Ivy.xml:

 

 

 

 

 

 

 

 

 

 

rev=”1.5.1″ transitive=”false”/>

 

 

 

 

 

 

 

 

 

 

 

Ivysettings.xml:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Install Cucumber:

 

 

 

Run the command { gum install cucumber} via command prompt anda message displayed after successful installation and also check through command {cucumber –help}.

 

 

 

 

 

Compile and Run the Project through Cucumber:

 

Go into project directory and enter a command on command prompt

 

{ant –Divy=true –Dgems=true}.

 

Please let us know if you have any queries or questions on above.

Thanks,

Rohit Singh

www.360logica.com