BDD utility scripts

In order to make the BDD process as friction-less as possible the following scripts have been added:

  • xtp-pull: Command line script that can retrieve/create feature files for specified ticket.

  • xtp-push: Command line script that can upload feature files for specified ticket.

  • xtp-compare: Command line script that can compare feature files locally with the corresponding one in Jira

These scripts will ensure tests, test sets and test results in Jira are often updated and kept in sync with what is stored in git repos.

Usage

Retrieve feature file

For retrieving feature files, this is as simple as:

xtp-pull --username jira-user --password your-password --xtp-ticket XTP-1080 --output-path preferred/output/path

output-path is optional and would default to your current path if not specified.

Push feature file to Jira

This utility uploads a feature file (cucumber format) to Jira. To use this you have to

  • Ensure that a test set exists in Jira that you want to upload the feature file to.

  • A feature file in the format below. Make sure the first line is the tag of the test set.

@XTP-1834
Feature: Test Upload feature file 3. As a user, I can calculate the sum of 2 numbers

    Scenario Outline: Upload .feature file test ticket
        Given I have entered <input_1> into the calculator
        And I have entered <input_2> into the calculator
...

If the Scenario Outline in the feature file matches the summary attribute on a Jira ticket that ticket will be updated. Otherwise a new Test ticket will be created.

The Test ticket will be associated with the Test Set.

The push functionality works as follows:

~/.local/bin/xtp-push --help

usage: xtp-push [-h] -f FEATURE_FILE -u USERNAME [-p PASSWORD] [-v]

optional arguments:
  -h, --help            show this help message and exit
  -f FEATURE_FILE, --feature-file FEATURE_FILE
                        Path to the feature file.
  -u USERNAME, --username USERNAME
                        JIRA account username
  -p PASSWORD, --password PASSWORD
                        Password for specified user. If not specified you will
                        be prompted for one
  -v, --verbose         Verbose output

Compare a local feature file with one on Jira

This utility ensures that the feature file locally is in line with what is in Jira.

A feature file that that has been exported from Jira would have a number of scenarios that are tagged with XTP-tickets. E.g

Feature: Default

    @XTP-1834
    Scenario Outline: Upload .feature file test ticket
        Given I have entered <input_1> into the calculator

These tags are used to pull the Jira ticket from Jira and this is then compared to the local feature file.

The utility works as follows:

usage: xtp-compare [-h] (-d DIRECTORY | -f FEATURE_FILE) [-p PASSWORD]
                   (-u USERNAME | -b BASIC_AUTH_TOKEN) [-v]

optional arguments:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        Path to the location of a directory of '*.feature'
                        files
  -f FEATURE_FILE, --feature-file FEATURE_FILE
                        Path to the location of a '*.feature' file
  -p PASSWORD, --password PASSWORD
                        When authenticating with a username, you will be
                        prompted for a password if you don't use this option
  -u USERNAME, --username USERNAME
                        JIRA account username
  -b BASIC_AUTH_TOKEN, --basic-auth-token BASIC_AUTH_TOKEN
                        HTTP Basic authentication token.
  -v, --verbose         Verbose output

All inconsistencies will be written to stdout.

Upload xray results to JIRA

The xtp-xray-upload script posts the results of the cucumber json file to JIRA. It is setup to run as a job in the skampi pipeline but can be installed and executed from the terminal.

The utility works as follows:

usage: xtp-xray-upload [-h] -f CUCUMBER_FILE [-u USERNAME] [-p PASSWORD] [-v]

Uploads a cucumber results file to JIRA by way of the XRAY extension. Either
use username/password or set the environment variable JIRA_AUTH for
authentication.

optional arguments:
  -h, --help            show this help message and exit
  -f CUCUMBER_FILE, --cucumber-file CUCUMBER_FILE
                        Path to the cucumber JSON results file.
  -u USERNAME, --username USERNAME
                        JIRA account username
  -p PASSWORD, --password PASSWORD
                        Password for the JIRA user. If not specified and the
                        environment variable `JIRA_AUTH` is not set then you
                        will be prompted for one.
  -v, --verbose         Verbose output