- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is the Example keyword in Cucumber?
We can perform data-driven testing with the help of keyword Examples. We shall also take the help of keyword Scenario Outline to execute the same Scenario over multiple values.
The data sets to be taken into consideration shall be passed below the Examples section one after another separated by | symbol. So, if there are three rows, we shall have three test cases executed from a Single scenario.
Also, the Given step has the <> delimiter. It points to the header of the Examples table. SpecFlow shall put the values within this table prior to the task of matching a step with a step definition.
To verify a Login module, we require the below steps to be executed −
- User types the username and password.
- Verify users should be able to log in.
We shall incorporate the above steps into the Feature File.
Feature File
Feature: User credential
Scenario Outline: Login module
Given user types <username> and <password>
Then user should be able to login
Examples
| username | password |
| tutorialspoint1| pwd |
| tutorialspoint2| pwd1 |
Example
Step Definition File
using System; using TechTalk.SpecFlow; namespace SpecFlowProject1.Features { [Binding] public class UserCredentialSteps { //regular expression used to point to data [Given(@"user types (.*) and (.*)")] public void GivenUserTypesUserAndPwds(string username, string password) { Console.WriteLine(username); Console.WriteLine(password); } [Then(@"user should be able to login")] public void ThenUserShouldBeAbleToLogin() { Console.WriteLine("User should be able to login"); } } }
Output
- Related Articles
- What is the Background keyword in Cucumber?
- What is the Scenario Outline keyword in Cucumber?
- What is Cucumber dry run in Selenium?
- What is the yield keyword in JavaScript?
- What is the const Keyword in C++?
- Keyword Driven Testing Framework with Example
- What are the main file components in Cucumber?
- What is the use of "is" keyword in C#?
- What are the advantages of using Cucumber?
- What is the native keyword in Java for?
- What is Keyword Streaming?
- What is volatile keyword in C++?
- What is "namespace" keyword in PHP?
- What is "out" keyword in Kotlin?
- What is the 'new' keyword in JavaScript?
