Simple Cucumber Script – Add Two Numbers

 

Pre-Requisites:

You have completed Ruby, selenium, cucumber installation steps described at the beginning of the tutorial. You have also downloaded the template project, imported in RubyMine.

 

Agenda:

  1. Intent is to add two numbers a and b and output the sum (a+b)
  2. Write First cucumber feature file 
  3. Write first scenario in the feature file
  4. Execute the scenario as is (It will fail since we did not write step definitions)
  5. Complete the code-behind (aka. step definitions) each step for the scenario
  6. Execute the scenario again
  7. The scenario passes and all steps pass too (GREEN as in Cucumber)
  8. The entire video is posted at the end ofComplete First Automation Script

 

1. Open the template project in RubyMine

 

opened_in_rubymine

2. Run Tools -> bundler -> Install

 

bundler_install

 

3. Just click Install

 

bundler_no_options

 

4. bundler install should pass as below and Gemfile.lock is created

bundler_complted

 

5.  Now right-click on features folder and click New -> File

 

new_feature_file

 

 

6. Name as “addition.feature”

 

addition_feature

 

7. Copy and paste the below content in addition.feature file (Double click the addition.feature file to open on the right window)

 

 

 

addition_feature_details

 

8. Just run the scenario as is

 

addition_run_no_steps

 

9. You will notice the error as below (unimplemented step definitions). This is perfectly alright, since we have not written the automation code yet

 

addition_unimplemented_steps

 

 

At this point, we will start writing the automation scripts. Continue……