Cucumber BDD Framework

Basics of Behaviour Driver Development

Often there is a Problem of Secifying the needs of the Business, communicate it to Development and Testing. There are mismatches between their perceptions.

-> write a Requirement in a formal standa…


This content originally appeared on DEV Community and was authored by Anne Quinkenstein

Basics of Behaviour Driver Development

Often there is a Problem of Secifying the needs of the Business, communicate it to Development and Testing. There are mismatches between their perceptions.

-> write a Requirement in a formal standard/ template in a language which is a common words. Dev, QA and Business can express the Requriment in that language.

Image description

Scenario template

In order to (achieve something/ Business Outcome)
as a (user)
i want to do (this).

Example:
In oder to pay credit card payment
as a NetBanking sole owner who has credit section access
i want to navigate to credit card section, enter amount and process my payment.

Dev uses this scenario to develop & tester uses it to write testcases(positiv & negativ /Payment is not happening)

Testcases

Given (what you need to have to perform an action)
When (performs action)
Then (desired outcome for the user)

Example:
Given: An account with sero balance
When: i navigate to Credit card Payment Section and click to submit by giving amount
Then: it should show a warning - funds

Given : An account with sufficent balance who does not have credit card
When: I navigate to Credit card Payment Section and amount
Then :You don't have to access /warning message

Business values are easy detectable. (in scenario)
Testcases are countable for each scenario.
Using a standard template for both manual and automation testing.

Cucumber Framework Architecture & Core Functionalities

Setup

Install Cucmber Plugin into eclipse from eclipse market place
Cucumber expects a Selenium scaletton, optains by Maven
Open a Maven Project with quickstart template (maven-architect-template)
Artifactid and GroupId(Projectname)
Maven: libaries in pom.xml: Cucumber JVM Java && Cucumber JVM JUnit

Cucmber Core Functionalities

Feature File - "When i click on button"
StepDefinition File - mapped Code to click button
JUnit TestRunner - triggers all Testcase (related Documents)

Feature File

under src/test/java create Package features
inside create "file" - zB Login.feature (provide .feature)

Feature: Application Login 

Scenario: Home page default login 
Given User is on landing page 
When User is logging in with username and password
Then home page is populated 
And all infos about you bills is displayed

AddOn in Eclipse to highlight the cucumer Syntax: Natural 0.7...

Image description
-> no defition found (no code implementation yet)

StepDefinition File

under src/test/java create Package stepDefinition
under this, stepDefition Java Class

@Given("^User is on landing page$")
public void user_is_on_landing_lage()
{ //navigate to the landing page }
@When("^User is logging in with username and password$")
public void user_is_logging_in(){...}
@Then("^home page is populated$")
public void home_page_is_populated(){...}
@And("^all infos about you bills is displayed$")
public void all_infos_about_bills_are_displayed(){...}

create mapping stepDefinition
install Extention from Chrome Webstore: Tidy Gherkin app
Image description chrome://apps -> click, an window will open where you can paste your feature file and get the tidy cucumber java (or ...) code
(adjust package-/classname accourdingly to your code)

or just run tests and copy code from the konsole

jump from a featurefile-sentence -> to stepDefinition: Crtl + Click

Running Tests with TestRunner File

preferable under the same roof with the stepDefinitions Package src/test/java create Package cucumberOptions and in there class TestRunner
Annotations:

@RunWith(Cucumber.class)
@CUcumberOptions(
    features = "src/test/java/features", 
    glue="stepDefinitions")

packages stepDefitions + cucumberOptions should have same parents

variables
feature file: put it in double quotes -Code: display it as regular expression in Annotation of function + passed as arguments in Method (so nr. of arguments should match nr. of parameters)


This content originally appeared on DEV Community and was authored by Anne Quinkenstein


Print Share Comment Cite Upload Translate Updates
APA

Anne Quinkenstein | Sciencx (2021-11-17T18:27:42+00:00) Cucumber BDD Framework. Retrieved from https://www.scien.cx/2021/11/17/cucumber-bdd-framework/

MLA
" » Cucumber BDD Framework." Anne Quinkenstein | Sciencx - Wednesday November 17, 2021, https://www.scien.cx/2021/11/17/cucumber-bdd-framework/
HARVARD
Anne Quinkenstein | Sciencx Wednesday November 17, 2021 » Cucumber BDD Framework., viewed ,<https://www.scien.cx/2021/11/17/cucumber-bdd-framework/>
VANCOUVER
Anne Quinkenstein | Sciencx - » Cucumber BDD Framework. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/11/17/cucumber-bdd-framework/
CHICAGO
" » Cucumber BDD Framework." Anne Quinkenstein | Sciencx - Accessed . https://www.scien.cx/2021/11/17/cucumber-bdd-framework/
IEEE
" » Cucumber BDD Framework." Anne Quinkenstein | Sciencx [Online]. Available: https://www.scien.cx/2021/11/17/cucumber-bdd-framework/. [Accessed: ]
rf:citation
» Cucumber BDD Framework | Anne Quinkenstein | Sciencx | https://www.scien.cx/2021/11/17/cucumber-bdd-framework/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.