Saturday, April 22, 2023

 

BDD cucumber Secondary keywords in feature file

Secondary keywords in feature file


Below are some lists of secondary keywords which can be use in feature file while writing test case.

1. # (hash sign): -

hash(#) is used to comment the line in feature file. So for commenting any line in feature file, we can put # before the start of the line.

2. @ (at the rate of): -

@ is used for mentioning the tag name in feature file. Tag name is use for running a specific scenario in feature file. This can be at feature level, scenario level, Examples level and etc. One scenario can have multiple tag names. Example is given below.

#Here hash is used to comment this line.
@e2e  @regression
Feature: This is my first feature file
@smoke
Scenario Outline: This is scenario outline with example keyword
When Enter customer name <name>
@test 
Examples:
|name|
|kabir|
|khan|

3. | (pipe line sign):-

In “Examples” keyword, pipe (|) line is used for entering multiple fields test data in the steps. This also used for passing lists of items in specific test step. Example is given below.

Passing list parameters in cucumber from feature file to step definition.

Step in Feature file

And the lists are given below:
|Laptop|
|Kitchen|
|home_Appliances|

Step definition

@And("the list are given below:(.*)")
	public void ListOfItem(List<String> list) {
	    System.out.println(list);
	}
    

Passing parameters in cucumber feature file in step definition.

Step in Feature file

When Enter customer name <name>

@example
Examples:
|name|
|kabir|
|khan|

Step definition

@When("^Enter customer name (.*)$")
	public void enter_CustomName(String name) {
	   System.out.println("Scenario outline :- "+name);
	}
      

4. “”” (Three inverted comma):-

This symbol is used for putting large or multiple line text in the steps. Example is given below.

Step in Feature file

    
Then user able to see the large text:
"""
Below are the list of items which can be selected
user can select any value
"""

Step definition

    
@Then("user able to see the large text:(.*)")
	public void largeText(String text) {
	    System.out.println(text);
	}
    

5. “” (Double inverted comma):-

Double inverted comma is used to passing test data in the step. Example is given below.

Step in Feature file

Given user logged with "userID"
    

6. <> (greater than less than sign) :-

This is used for passing the reference of test data in test step from feature file. Example is given below.

Step in Feature file

And user select also select item <item>
    

Step definition

    
@And("^user select also select item ([^\\\"]*)$")
	public void navigate_to_home_page3(String Items) {
	    System.out.println(Items);
	}
    

7. “<>” (greater than less than sign with inverted comma):-

This also used for passing the reference of test data in the test step. Example is given below.

Step in Feature file

When user select item "<number>"
    

Step definition

@When("^user select item \\\"(.*)\\\"$")
	public void navigate_to_home_page2(String number) {
	    System.out.println(number);
	}
    

Related Posts:

  • What Is Hooks In Cucumber? What Is Hooks In Cucumber?Hooks is nothing but the script which run before or after each scenarios. There are some annotation which are used to execute script before or after each scenarioes.Below are the lists of cucum… Read More
  • How to pass the Parameter in BDD cucumber? How to pass the Parameter?Passing parameter by using “” (double quotes) OR <> signFrom feature file, we can pass a single parameter by using “” in the step.Example is given below.Step in Feature file Given user lo… Read More
  • Regular expression in step definition in cucumber Regular expression in step definitionBelow are some lists of special character that can be used while writing step definition.1. .(dot)-We can use any character in place of "." In below example, single step definit… Read More
  • What is BDD in selenium? What is BDD in selenium?BDD (Behavior Driven Development) is software development approach that allows developer or tester to create the script base on the behavior or functionality of the application.The steps of behav… Read More
  • Test Runner class in BDD Test Runner classTest runner class is the starting point in BDD from where the script get executed with the help of junit annotation. Test runner class use junit class annotation which is @Runwith(). This gets exec… Read More

1 comment:

Translate

Popular Posts

Total Pageviews

150,712