Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

We're using "curl" utility that comes in Unix based OS'es but you can easily use another tool to make the HTTP request; however, "curl" is provided in the container used by GitLab.



Cucumber example

Standard workflow (Xray as master)

In this scenario, we are managing the specification of Cucumber Scenarios/Scenario Outline(s) based tests in Jira, using Xray, as detailed in the "standard workflow" mentioned in Testing in BDD with Gherkin based frameworks (e.g. Cucumber)

Then we need to extract this specification from Jira (i.e. generate related Cucumber .feature files), and run it in GitLab against the code that actually implements each step that are part of those scenarios.

...

In this example, we're using a variable cucumber_keys defined in the CI/CD project level settings in GitLab. This variable contains one or more keys of the issues that will be used as source data for generating the Cucumber .feature files; it can be the key(s) of Test Plan(s), Test Execution(s), Test(s), requirement(s). For more info, please see: Exporting Cucumber Tests - REST.

VCS workflow (Git as master)

In this scenario, we are managing (i.e. editing) the specification of Cucumber Scenarios/Scenario Outline(s) based tests outside Jira, as detailed in the "VCS workflow" mentioned in Testing in BDD with Gherkin based frameworks (e.g. Cucumber).


The GitLab configuration file .gitlab-ci.yml contains the definition of the build steps, including synchronizing the Scenarios/Backgrounds to Xray, extracting the cucumber specification from Xray, running the automated tests and submitting back the results.
.gitlab-ci.yml

image: "ruby:2.3"
 
test:
  script:
  - apt-get update -qq
  - apt-get -y install unzip zip
  - gem install cucumber
  - gem install rspec-expectations
  'cd features; zip -R features.zip "*.feature"; cd ..; curl -H "Content-Type: multipart/form-data" -u $jira_user:$jira_password -F "file=@features/features.zip" "$jira_server_url/rest/raven/1.0/import/feature?projectKey=CALC" '
  'rm -f features/*.feature'
  'curl -u $jira_user:$jira_password "$jira_server_url/rest/raven/1.0/export/test?filter=$filter_id" -o features/features.zip'
  - unzip -o features/features.zip -d features/
  - cucumber -x -f json -o data.json || true
  'curl -H "Content-Type: application/json" -u $jira_user:$jira_password --data @data.json "$jira_server_url/rest/raven/1.0/import/execution/cucumber"'
  - echo "done"


In this example, we're using a variable filter_id defined in the CI/CD project level settings in GitLab. This variable contains the id of the Jira issues based filterhat will be used as source data for generating the Cucumber .feature files; it can be the key(s) of Test Plan(s), Test Execution(s), Test(s), requirement(s). For more info, please see: Exporting Cucumber Tests - REST.