Gherkin is the Business Readable, Domain Specific Language, which serves as your project's documentation and automated tests. It is a non-technical and human-readable language that collectively describes use cases relating to a software system.
Why Gherkin Language
- Translate in many languages: Gherkin's syntax is not bound to one particular spoken language. You can translate Gherkin's keyword into more than forty different spoken languages.
- Easy to Understand: Gherkin's Primary goal is human readability. Gherkin is designed to be easy to learn by non-programmers, and it is structured enough to allow the concise description of examples to illustrate business rules in most real-world domains.
- Logic and Behavior Separation: It gives you the ability to remove logic details from behavior tests.
- Less Documentation: Gherkin is created explicitly for behavior descriptions. You can write your project requirement in Gherkin language, and same you can reuse and modify it as your manual and automation tests.
- Supported Tools: Many BDD tools like Cucumber, Behat, SpecFlow, etc., use Gherkin as the primary language of writing tests.
- Save Time and Money: Clear and better communication is most important while building software. Because of misunderstanding, there is a possibility that code that we have worked hard for several days has been thrown away when we have developed what was not required. Using Gherkin, we can avoid such waste of time and money.
Example Scenario written in Gherkin Language
Given I am on the home page When I Click on Login Link And I fill in username with "xyz" And I fill in password with "abc" And I click on Login button Then I should see My Account Page
This is a sample Gherkin Scenario for Login functionality written in the English Language.
In the same way, you can write your project stories and manual test in the language of your choice and map these Gherkin Steps to your automation code.