Book Image

Cucumber Cookbook

By : Shankar Garg
Book Image

Cucumber Cookbook

By: Shankar Garg

Overview of this book

Table of Contents (13 chapters)
Cucumber Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a Feature file in a language other than English


Most of us have worked in teams spanning multiple geographies, and we would agree that some of us are more comfortable in native languages as compared to English. We are able to express ourselves better, and we are also able to express everything. So what if our BA or PO is more comfortable in Danish compared to English? Let's write the specification in a language other than English in Cucumber.

How to do it…

This is a sample English Feature file, which we will convert into different languages.

Feature: sample application
  In order to test login page
  As a Registered user
  I want to specify the login conditions

  Scenario: sample scenario
    Given user is on application page
    When user clicks login button
    Then user is on home page

To create the Feature file in Danish (Danish.feature):

# language: da
Egenskab: prøve ansøgning
     For at teste login side
     Som registreret bruger
     Jeg ønsker at angive login betingelser

  Scenarie: prøve scenario
    Givet brugeren er på ansøgning side
    Når brugeren klikker login knap
    Så Derefter bruger er på hjemmesiden

How it works…

Cucumber allows us to write Feature files in around 40 spoken languages, thus empowering the teams whose first language is not English to write Feature files which are as robust as English language Feature files. The header # language: da in the first line of the Feature tells Cucumber what language will be used in the Feature file. By default, the language is English. If we want to write Feature files in another language, the Feature files must be saved with "UTF-8" encoding.

In a single project, we can have Feature files in multiple languages; but for one Feature file, only one language will work.

Note

For all languages, there is no difference in how Step definitions are generated.