• Home
  • Testing
  • SAP
  • Web
  • Must Learn!
  • Big Data
  • Live Projects
  • AI
  • Blog

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 http://rubyinstaller.org/downloads/

Step 2) Open the downloaded file.

  1. Accept license
  2. Click on Next button

Step 3) In next screen.

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

Step 4) In the following screen, Click on Next

Step 5) Wait for installation to complete.

Step 6) Click Finish

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

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

Install Cucumber

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

After few seconds cucumber installation procedure has been start

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

Install IDE RubyMine

Step 1)

Step 2)

Step 3)

Step 4)

Step 5)

Step 6)

Step 7)

Step 8)

Step 9)

Step 10)

Step 11)

Step 12)

Install watir-webdribver

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

Step 2) watir-webdriver install successfully

First Cucumber Script

Step 1) Open RubyMine Editor via windows start menu

You will See Rubymine Dashboard as below

Step 2) Create a new project in Rubymine editor

Step 3) create a file directory

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

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

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"

It will look like this!

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

Create a new folder in Rubymine editor

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

Step 9) Write the following code into the step file

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:

The result is

 

YOU MIGHT LIKE: