You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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 is exported using the UI or the REST API.

Requirements

  • 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 (see bellow) and generating the Behave JSON  report (e.g. data.json), it can be imported to Xray (either by the REST API or through "Import Execution Results" action within the Test Execution).

behave --format=json -o data.json

 

The execution details shows the result of the Cucumber Scenario.

 

Learn more

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

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

 

References

 

  • No labels