Cucumber Installation

In previous post we have just seen introduction about Cucumber, now we will see in details how to do setup.

Pre-requisite. 
Install JDK
Install and configure Maven
Install and configure Eclipse (with plugins)
Set up selenium web driver component


Agenda

Here we will write our first cucumber script and run through runner class .



  1. Download Cucumber Jars from Maven dependencies
  2. cucumber-jvm and other dependent jars
  3. Project structure
  4. Cucumber first feature
  5. Write step definitions (automation code)
  6.  Runner class
  7. Results

  1. Download Cucumber Jars from Maven dependencies

This is the easiest way to configure the other way is to download all one by one jar from maven repository. 

 There are few prerequisites for setting up cucumber in eclipse.
  1. Install Maven in Eclipse IDE
  2. Create a New Maven Project in Eclipse

Once Maven is installed on eclipse and a Maven project is created, the next step is to add cucumber dependencies on the project. SO  we need to add dependencies in POM.xml file to point all the jars like 
  1.  cucumber-core
  2. cucumber-java
  3. cucumber-junit
  4. cucumber-jvm-deps
  5. cucumber-reporting
  6. gherkin
  7. junit

Please update the pom.xml as shown below. and also make sure that to paste from properties tag. 



3. TO understand project structure 

  • src/main/java: This will ideally contain source code
  • src/test/java: This will contain all java code that runs automation
  • src/test/resources: This will contain our feature files
  • features: This folder contains all the feature files

4 . To create first cucumber feature file 

under src/test/resource folder create feature file. 
if folder not exists please create a source folder like this





and in the popup name the folder as -> src/test/resources 




Create a feature file as sample.feature under this folder as show in below snapshot from project right click and navigate to File in popup below show enter the file name. 



Then copy paste this feature file snippet. 




5. Create Step definition for the corresponding feature file
right click on the src/test/java and create a new class as stepDefinition with below content 



7. Right click on class RunCukesTest and run as Junit Test







7. Go to target -> cucumber-html-report and the report should look like this.







That;s it, you are done with the basic cucumber setup till report.

Thanks