Параметризация объекта в огурце - PullRequest
0 голосов
/ 29 января 2020

У меня есть ситуация, когда я использую один и тот же набор параметров для каждого плана сценария в моем наборе тестов (я использую javascript):

Feature: Select a Product
  Install Checklist for Product

  Scenario Outline: functionA() is called on page type <type> -- No errors
    Given I load the site and go to a <type> page
    Then I should see no errors are thrown

    Examples:
      | type |
      | "product" |
      | "home" |
      | "collection" |

  Scenario Outline: functionA() is called on page type <type> -- Minimal delay
    Given I load the site and go to a <type> page
    Then there is a minimal delay before calling functionA()

    Examples:
      | type |
      | "product" |
      | "home" |
      | "collection" |

  Scenario Outline: functionA() is called -- correct type <type>
    Given I load the site and go to a <type> page
    Then the page type is <type>

    Examples:
      | type |
      | "product" |
      | "home" |
      | "collection" |

  ...many more tests using an identical Examples array

Я хочу улучшить структура этого кода и лучший способ сделать это - поместить секцию Examples вне отдельного Scenario Outlines в качестве глобальных параметров. По сути, я хочу запустить каждый из этих Scenarios с каждой из записей в Examples без необходимости повторять массив Examples для каждого Scenario. Я уверен, что вы видите, что в будущем изменение массива Examples будет громоздким.

Есть ли способ сделать это в Cucumber?

Что-то вроде:

Feature Outline: Select a Product
  Install Checklist for Product

  Scenario Outline: functionA() is called on page type <type> -- No errors
    Given I load the site and go to a <type> page
    Then I should see no errors are thrown

  Scenario Outline: functionA() is called on page type <type> -- Minimal delay
    Given I load the site and go to a <type> page
    Then there is a minimal delay before calling functionA()

  Scenario Outline: functionA() is called -- correct type <type>
    Given I load the site and go to a <type> page
    Then the page type is <type>

  ...many more tests using an identical Examples array

  Examples:
    | type |
    | "product" |
    | "home" |
    | "collection" |

или

Feature: Select a Product
  Install Checklist for Product

  Rule Outline: verify functionA() on page type <type>

    Scenario Outline: functionA() is called on page type <type> -- No errors
      Given I load the site and go to a <type> page
      Then I should see no errors are thrown

    Scenario Outline: functionA() is called on page type <type> -- Minimal delay
      Given I load the site and go to a <type> page
      Then there is a minimal delay before calling functionA()

    Scenario Outline: functionA() is called -- correct type <type>
      Given I load the site and go to a <type> page
      Then the page type is <type>

  ...many more tests using an identical Examples array

    Examples:
      | type |
      | "product" |
      | "home" |
      | "collection" |

Редактировать: Для тех, кто смотрит на это в будущем, я открыл соответствующую проблему здесь: https://github.com/cucumber/cucumber/issues/879

1 Ответ

1 голос
/ 29 января 2020

Вы можете попробовать использовать плагин qaf-cucumber , который позволяет повторно использовать примеры с помощью поставщика данных. Это расширение для корнишона с BDD2 синтаксисом

...