0

I want to add pre-steps to Scenario Outline as Scenario, but I don't want to add pre-condition. How can I do that in Jira Xray?

Some illustrative example:

Scenario:
    Given: Open website
    Then: Check URL

Scenario Outline:
    When I click this <button>
    Then Something happens with <this> element

I want to have some "background" for Scenario Outline because this is something that repeats in several tests but it turns out that for every step in S.Outline Background is repeating so I want to create a normal Scenario as "artificial" background. How to do that in Xray? Can I add something like pre-step? Pre-condition always creates "Background" in Gherkin.

I don't want to have several Scenario Outline scenarios with a lot of repeated steps.

beauvoir
  • 67
  • 1
  • 9

1 Answers1

1

This is more a Gherkin related question than Xray specific. There are no dependencies between Scenarios in Gherkin.

The way to have some initial Gherkin statements that apply to all to several Scenarios, is by having a Background in the corresponding .feature file. In Xray this means that you need to have a Precondition, of Cucumber type, with those Gherkin statements. Then you need to associate it all Tests (Scenario/Scenario Outline types) that you want. Whenever exporting those tests, a .feature file will be created with a Background corresponding to the previous Precondition. The rules for generating .feature files based on Test and Preconditions issues in Xray is detailed here.

Note: in Cucumber libraries there also hooks, that contain code that can be executed before/after tests. However, this is used for something that isn't described as behaviour and more for easing implementation, and doing things like test setup/cleanup.

Sérgio
  • 1,777
  • 2
  • 10
  • 12