Questions tagged [python-behave]

Behave is a BDD framework for Python, based on the Cucumber Framework.

Behave is Behaviour Driven Development (BDD) framework for Python. It follows the Gherkin syntax, which defines Scenarios and steps files.

A scenario is a human readable flow, for example:

Scenario: Calling the metadata API
   Given A matching server
   When I call metadata
   Then metadata response is JSON
   And response status code is 200

The steps file casts programmatic meaning to each line, for example:

...
@then('response status code is {expected_status_code}')
def step_impl(context, expected_status_code):
    assert_equals(context.response.status_code, int(expected_status_code))

@then('metadata response is JSON')
def step_impl(context):
    json.loads(context.metadata_response.data)
...

Behave combines the scenario and steps to a test report:

enter image description here

521 questions
6
votes
2 answers

Behave: How to import steps from another file?

I have just started using behave, a Pythonic BDD framework using Gherkin syntax. behave takes a feature, e.g.: Scenario: Calling the metadata API Given A matching server When I call metadata Then metadata response is JSON And response…
Adam Matan
  • 128,757
  • 147
  • 397
  • 562
5
votes
1 answer

How to only show failing tests from behave?

I've got a Python 3.4 project with tests built in the behave framework (version 1.2.5). When I run the tests, I get several hundred lines of output, most of it describing steps that passed with no problems. When a scenario fails, I need to scroll…
Alan
  • 192
  • 1
  • 8
5
votes
2 answers

how to fail the step explicitly in behave step implementation

I want to explicitly fail the step in behave when I encounter an exception eg. I am writing the code according to behave documentation - from behave import * @when('verify test fails.*?(?P.*)') def test_logger(context, param_dict): …
pythonuser
  • 197
  • 5
  • 10
5
votes
2 answers

How to run a feature file using Pycharm Community

I have installed the behave 1.2.5 and PyCharm Community. When I right click the feature file I do not see an option called Run as feature file. How do I set the Run configuration
Ashok kumar Ganesan
  • 1,098
  • 5
  • 20
  • 48
5
votes
1 answer

Multiple python Behave environment Setup files

I'm trying to break away from some standards in the behave framework and running into some issues. Is it possible to have multiple environment.py files that have the before* and after* hooks? I'm writing a test harness for a suite of microservices.…
bgura
  • 860
  • 15
  • 33
5
votes
1 answer

Python behave running from python2.7 rather than python3.4

When I run behave it seems to run from python2.7 and fails to find selenium, which is installed for python3.4. Do I need to configure behave to run python3.4 somewhere - I can see nothing on the behave site, or elsewhere. There are posts about using…
MikeJ
  • 53
  • 1
  • 3
4
votes
1 answer

PyTest-BDD Single Scenario Outline Multiple Examples

I'd like to define a single PyTest-BDD based Scenario Outline that has multiple Examples. Sample snippet: Scenario Outline: front to back validation When tester executes access view sql query into av dataframe …
Walter Kelt
  • 2,199
  • 1
  • 18
  • 22
4
votes
1 answer

Behave run features in random order

I have 10 features with 10 different step functions written in python using behave library. They are all independent of each other, to show that i have to run them in random order. Right now behave is running them alphabetically with behave -i tag.…
Egeio
  • 51
  • 3
4
votes
0 answers

How to run feature file scenarios through Test Explorer in Python VS Code?

I am trying to run my Behave scenarios in VS Code through test explorer. My feature file and steps file are properly bind as the same project works on Pycharm Professional Edition (trail version). I do not see my test explorer loading my…
4
votes
4 answers

Ambiguous Step exception shown for different step names in python behave

I have two different python file under steps directory: driverlogon.py and triplogon.py driverlogon.py defines the step @when(u'enter the {driver_id}') def step_enter_the_driver_id(context,driver_id): …
SophoPhile
  • 45
  • 4
4
votes
0 answers

Testing Amazon Quicksight Implementation

My organisation are looking to move to Amazon Quicksight to replace our existing reporting solution. As part of the review before we move I have been asked to investigate the options for creating automated tests for the Quicksight implementation,…
Richard C
  • 513
  • 1
  • 7
  • 26
4
votes
1 answer

Python Behave tests not running on bitBucket CI

We have a Simple Python Behave based test suite. It runs fine on local environment. Command used to run test: pip3 install -r requirements.txt behave -D URL=https://api.ourUrl.org/test/shopping There's an optional npm based Allure report…
user2451016
  • 1,857
  • 3
  • 20
  • 44
4
votes
4 answers

How to run a pytest-bdd test?

I am not understanding how to properly run a simple test(feature file and python file) with the library pytest-bdd. From the official documentation, I can't understand what command to issue to run a test. I tried using pytest command, but I saw the…
Shamsul Arefin
  • 1,771
  • 1
  • 21
  • 21
4
votes
1 answer

Parameterize behave feature, pytest-style

I'm looking run behave feature tests repeatedly, but each one with different parameters, a bit like pytest's parameterize https://docs.pytest.org/en/latest/reference.html#pytest-mark-parametrize-ref I'm unable to find anything that suggests this can…
Michal Charemza
  • 25,940
  • 14
  • 98
  • 165
4
votes
1 answer

how to pass variable argument to context.execute_steps in python-behave

I want to execute certain step before executing my function. The step takes variable as an argument. I am not able to pass it in context.execute_steps. eg. call1 = "version" call1_method = "get" context.execute_steps('''When execute…
pythonuser
  • 197
  • 5
  • 10
1 2
3
34 35