Cucumber BDD Framework

Cucumber BDD Framework

Cucumber-jvm is an open source BDD (Behavior Driven Development) tool that lets user express the behavior of system under test in plain English. It is a great way to have an executable documentation of your system.
For reference please click on the links mentioned below:

For an example, think of writing a simple addition program. If you were to practice BDD, the team
should get together to define the expected behavior such as:

  • should perform addition of two positive number
  • should perform addition of a positive and a negative number
  • should perform addition of two negative number
  • should perform addition for decimal numbers upto 2 digits and likewise

 Gherkin is a plain English text language, which helps the tool – Cucumber to interpret and execute the test scripts.
Example

  • Feature – User Access Management for a social networking site.
  • Scenario– Verify Authentication Functionality
  • Given I am a social networking site user.
  • When  I enter username as username1.
  • And I enter password as password1.
  • Then I should be redirected to the home page of the site.

SLNO

Pre-Condition

Test step

Test Data

Expected

Actual

Given

When

Single Value/ Parameters

Then

  1. Create a Maven Project.

Cucumber BDD Framework

Cucumber BDD Framework

  1. Click on Next->Next->New Maven project. Enter the following details of New Maven Project.

ArtifactID->TotalQACucumberFwk

package->org.totalqa

GroupID->org.totalqa

Cucumber BDD Framework

Click on Finish button to create the Maven Project.

  1. Open pom.xml created in the Project. Provide the cucumber-jvm, cucumber-java dependencies in the pom.xml as mentioned below:
  2. Download the cucumber plugin in eclipse. Access Help->Eclipse Marketplace. Type cucumber and click install.

Cucumber BDD Framework

Cucumber BDD Framework

  1. Restart the Eclipse once the plugin is installed successfully.
  2. Right click on the project and select the New ->Folder to create a folder under the project.

Provide name as ‘cucumberfeatures’.

Cucumber BDD Framework

  1. Right click on the folder->Select File as shown file. Provide the file name as ‘login.feature’.

Cucumber BDD Framework

  1. Open the File ‘login.feature’ and provide the details mentioned below
  2. Create a package as ‘com.cucumber.tests’ under src/test/java folder.

Cucumber BDD Framework

10 . Create a Java Class named “LoginTest.java” using the following code under the package com.cucumber.tests.

Link the Feature file to the Java Class

@CucumberOptions(features=”cucumberfeatures/Login.feature”)

  1. Right click on the Java class->Run As->Junit Test

Cucumber BDD Framework

11 .Check the results in the Junit Tab and console.

Cucumber BDD Framework

Cucumber-JVM installation is done successful.

  1. Right click on the Java class->Run As->Junit Test.

Cucumber BDD Framework

  1. Once the program is executed successfully. Check the contents of the Console.

Cucumber BDD Framework

  1. Copy the contents of the console to the another page object program created under the package ‘com.cucumber.pages’.

Cucumber BDD Framework

  1. Contents of the Page Object program shown below:
  2. Update the Test Program to attach the Pages using the glue code.
  1. Execute the Test Program by right click run as Junit Program.

Cucumber BDD Framework

https://sukesh15.gitbooks.io/cucumber-jvm-test-framework-/content/getting_started/get_the_cucumber-jvm_plugin.html

Leave a Reply

Your email address will not be published. Required fields are marked *