Recherche…


Introduction

Vous pouvez utiliser le concombre comme plug-in dans QTP et Selenium. Les étapes du scénario du concombre sont des variables globales. Vous pouvez implémenter une fois et appeler plusieurs fois. De ce fait, réduit la maintenance du code et peut réutiliser le même code si nécessaire.

Remarques

Les fonctions de concombre sont écrites dans le langage Gherkin et stockées dans des fichiers avec le suffixe .feature . Cette rubrique donne des exemples de chaque fonctionnalité de Gherkin.

Une fonctionnalité minimale de concombre

Dans fonctionnalités / documentation.feature:

Feature: Documentation

  Scenario: User views documentation
    When I go to the "Cucumber" documentation
    Then I should see the "Cucumber" documentation

Une fonctionnalité minimale possède une ligne de Feature et un Scenario comportant une ou plusieurs étapes commençant par When , Then ou un autre mot-clé Gherkin.

Un scénario judicieux aurait probablement plus d’une étape.

Plan du scénario

Modèle comme ci-dessous

Scenario Outline: As a homemaker i want to buy and pay for the below product
  Given I purchase <a product>
    And I require a carry bag to take things to home
  When I pay bill using <payment method> to successfully checkout
  Then I should have a receipt

Examples:
| a product     | payment method |
|  Cake         | Visa           |
|  Coke         | Paypal         |

Utilisation de la syntaxe

Feature: Some terse yet descriptive text of what is desired
     Textual description of the business value of this feature
     Business rules that govern the scope of the feature
     Any additional information that will make the feature easier to understand

Background:
    Given some precondition needed for all scenarios in this file
        And another precondition

Scenario: Some determinable business situation
  Textual description of the business value of this scenario
  Business rules that govern the scope of the scenario
  Any additional information that will make the scenario easier to understand
    Given some precondition
      And some other precondition
    When some action by the actor
      And some other action
      And yet another action
    Then some testable outcome is achieved
      And something else we can check happens too
      But something else we can check does not happen

Scenario Outline: Some determinable business situation
    Given I am <precondition>
        And some other precondition
    When some action by the actor
    Then I have <outcome> rights

Examples:
    | precondition | outcome  |
    | username1    | customer |
    | username2    | admin    |

Les mots-clés suivants sont interchangeables, mais selon le contexte, il peut être préférable d'utiliser:

  • Feature: | Ability: | Business Need:
  • Scenario Outline: | Scenario Template:
  • Examples: | Scenarios:
  • Given | When | Then | And | But | * |


Modified text is an extract of the original Stack Overflow Documentation
Sous licence CC BY-SA 3.0
Non affilié à Stack Overflow