How to Download & Install CUCUMBER in Windows

Cucumber installation could be tiresome but its relatively easy.

Here is a roadmap of components that need to be installed to make Cucumber work

Install Ruby and DevKit

Step1) Got to https://rubyinstaller.org/downloads/

Install Ruby and DevKit

Step 2) Open the downloaded file.

  1. Accept license
  2. Click on Next button

Install Ruby and DevKit

Step 3) In next screen.

  1. Select your Installation Directory
  2. Select all Options
  3. Click Install

Install Ruby and DevKit

Step 4) In the following screen, Click on Next

Install Ruby and DevKit

Step 5) Wait for installation to complete.

Install Ruby and DevKit

Step 6) Click Finish

Install Ruby and DevKit

Step 7) Once installation is complete, Lets Run Ruby!

Install Ruby and DevKit

Step 8) You will see Ruby Command prompt similar to Windows cmd.

Install Ruby and DevKit

Install Cucumber

Step 1) Type in Ruby cmd “gem install cucumber”. This command will download and install Cucumber at command line itself

Install Cucumber

After few seconds cucumber installation procedure has been start

Install Cucumber

Step 2) To verify cucumber is installed successfully or not just type “cucumber –version”

Install Cucumber

Install IDE RubyMine

You should follow the steps below to successfully Install IDE RubyMine.

Install IDE RubyMine

Step 1) Click Next to continue to Install IDE RubyMine.

Install IDE RubyMine

Step 2) Choose Install location

Install IDE RubyMine

Step 3) Installation Options

Install IDE RubyMine

Step 4) Choose the start menu folder

Install IDE RubyMine

Step 5) Click on Install

Install IDE RubyMine

Step 6) Click on Finish

Install IDE RubyMine

Step 7) Select Do not import settings.

Install IDE RubyMine

Step 8) Click on Evaluate

Install IDE RubyMine

Step 9) Accept the license

Install IDE RubyMine

Step 10) Skip Remaining and set defaults

Install IDE RubyMine

Step 11) Open

Install IDE RubyMine

Step 12) Create a new project

Install IDE RubyMine

Install watir-webdriver

Step 1) Click on “Start Command Prompt With ruby” and install command “gem install watir-webdriver”

Install watir-webdriver

Step 2) watir-webdriver install successfully

Install watir-webdriver

First Cucumber Script

Step 1) Open RubyMine Editor via windows start menu

Cucumber Script

You will See Rubymine Dashboard as below

Cucumber Script

Step 2) Create a new project in Rubymine editor

Cucumber Script

Cucumber Script

Step 3) create a file directory

Cucumber Script

Cucumber Script

Step 4) create and Save File in “yourfolder/features/” with name “yourfilename.feature”

Cucumber Script

Cucumber Script

Step 5) To execute our scenario, save the following commands in the Feature File

Cucumber Script

Code:

Feature: Multiplication 
I multiply two numbers 
	Scenario: multiply a and b 
		Given I have variable a 
		And I have variable b 
		When I multiplication a and b 
		Then I display the Result

Step 6) Now lets Run our First feature file.!

Click on “Start Command Prompt With ruby”

Cucumber Script

It will look like this!

Cucumber Script

Step 7) Lets create step definition file for our Feature File!

Create a new folder in Rubymine editor

Cucumber Script

Cucumber Script

Step 8) Save File As below in “yourfolder/features/step_definititons” with name test_step.rb

Cucumber Script

Cucumber Script

Step 9) Write the following code into the step file

Cucumber Script

Code :

Given(/^I have variable a$/) do
@a = 50
end

And(/^I have variable b$/) do
@b = 70
end

When(/^I multiplication a and b$/) do 
@mul = @a * @b
end

Then(/^I display the Result$/) do 
puts "Multiplication of #{@a} and #{@b} is #{@mul}"
end

Step 10) Now, again run our feature file:

Cucumber Script

The result is

Cucumber Script