![]() ![]() It is typically something that happened in the past. Given steps are used to describe the initial context of the system - the scene of the scenario. Then my account should have a balance of £430 This might seem like a limitation, but it forces you to come up with a less ambiguous, more clearĭomain language: Given my account has a balance of £430 Given, When, Then, And or But step with the same text as another step.Ĭucumber considers the following steps duplicates: Given there is money in my account Keywords are not taken into account when looking for a step definition. When Cucumber tries to execute a step, it looks for a matching step definition to execute. Describe an expected outcome ( Then steps)Įach step starts with Given, When, Then, And, or But.Ĭucumber executes each step in a scenario one at a time, in the sequence you’ve written them in.Describe an initial context ( Given steps).In addition to being a specification and documentation, an example is also a test. Having too many steps will cause the example to lose its expressive power as a specification and documentation. You can have as many steps as you like, but we recommend 3-5 steps per example. The keyword Scenario is a synonym of the keyword Example. This is a concrete example that illustrates a business rule. A Rule should contain one or more scenarios that illustrate the particular rule.įor example: # - FILE: features/le_example.featureĮxample: Two - Dead and Reborn as Phoenix It provides additional information for a feature.Ī Rule is used to group together several scenarios The purpose of the Rule keyword is to represent one business rule that should be implemented. Yet if you encounter issues, check the documentation of your Cucumber implementation to make sure it supports it. It has been ported in a lot of Cucumber implementation already. The (optional) Rule keyword has been part of Gherkin since v6. You can write anything you like, as long as no line starts with a keyword.ĭescriptions can be in the form of Markdown - formatters including the official HTML formatter support this. Descriptionsįree-form descriptions (as described above for Feature) can also be placed underneathĮxample/ Scenario, Background, Scenario Outline and Rule. Independent of your file and directory structure. You can place tags above Feature to group related features, ![]() The free format description for Feature ends when you start a line with the keyword Background, Rule, Example or Scenario Outline (or their alias keywords). Their purpose is to provideĪ place for you to document important aspects of the feature, such as a brief explanationĪnd a list of business rules (general acceptance criteria). The name and the optional description have no special meaning to Cucumber. Is over when the Breaker guesses the Maker's word. The Maker makes a word for the Breaker to guess. The word guess game is a turn-based game for two players. These description lines are ignored by Cucumber at runtime, but are available for reporting (they are included by reporting tools like the official HTML formatter). You can add free-form text underneath Feature to add more description. The first primary keyword in a Gherkin document must always be Feature, followedīy a : and a short text that describes the feature. Of a software feature, and to group related scenarios. The purpose of the Feature keyword is to provide a high-level description Gherkin is localised for many spoken languages each has their own localised equivalent of these keywords. There are a few secondary keywords as well: Scenario Outline (or Scenario Template).Given, When, Then, And, But for steps (or *).The only exceptions are the free-form descriptions placed underneath Example/ Scenario, Background, Scenario Outline and Rule lines. KeywordsĮach line that isn’t a blank line has to start with a Gherkin keyword, followed by any text you like. That should not be followed by one, your test(s) will be ignored. Please note that some keywords are followed by a colon ( :) and some are not. The trailing portion (after the keyword) of each step is matched to Then the Breaker must guess a word with 5 characters Given the Maker has started a game with the word "silky" Then the Maker waits for a Breaker to join Here is an example: Feature: Guess the word They begin with zero or more spaces,įollowed by a hash sign ( #) and some text.īlock comments are currently not supported by Gherkin.Įither spaces or tabs may be used for indentation. Most lines in a Gherkin document start with one of the keywords.Ĭomments are only permitted at the start of a new line, anywhere in the feature file. Each keyword is translated to many spoken languages Gherkin uses a set of special keywords to give structure and meaning toĮxecutable specifications. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |