Overview

In this tutorial, we will create some tests in Behave, which is a Cucumber variant for Python.

The test (specification) is initialy created in Jira as a Cucumber Test and afterwards, it is exported using the UI or the REST API.

Requirement

  • Install Behave

Code


features/tutorial01_basics.feature
Feature: Showing off behave (tutorial01)
@ABC-119
Scenario: Run a simple test
    Given we have behave installed
    When we implement a test
    Then behave will test it for us!

features/steps/step_tutorial01.py
# file:features/steps/step_tutorial01.py
# ----------------------------------------------------------------------------
# STEPS:
# ----------------------------------------------------------------------------
from behave import given, when, then
@given('we have behave installed')
def step_impl(context):
    pass
@when('we implement a test')
def step_impl(context):
    assert True is not False
@then('behave will test it for us!')
def step_impl(context):
    assert context.failed is False


After running the tests and generating the Behave JSON report (e.g., data.json), it can be imported to Xray via the REST API or  the Import Execution Results action within the Test Execution.

behave --format=json -o data.json


The execution details displays the result of the Cucumber Scenario.


Learn more

See the available endpoints for importing Behave's results in Import Execution Results - REST.

Testing with Cucumber details the typical workflow for Cucumber-related tests.


References