Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
November 17, 2021 06:27 pm GMT

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 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 passwordThen 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)


Original Link: https://dev.to/annequinkenstein/cucumber-bdd-framework-2n4o

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To