Giter Site home page Giter Site logo

behave.example's Introduction

behave

Latest Version License CI Build Status Documentation Status Discussions at https://github.com/behave/behave/discussions Chat at https://gitter.im/behave/behave

behave is behavior-driven development, Python style.

logo

Behavior-driven development (or BDD) is an agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project.

behave uses tests written in a natural language style, backed up by Python code.

First, install *behave*.

Now make a directory called "features/". In that directory create a file called "example.feature" containing:

# -- FILE: features/example.feature
Feature: Showing off behave

  Scenario: Run a simple test
    Given we have behave installed
     When we implement 5 tests
     Then behave will test them for us!

Make a new directory called "features/steps/". In that directory create a file called "example_steps.py" containing:

# -- FILE: features/steps/example_steps.py
from behave import given, when, then, step

@given('we have behave installed')
def step_impl(context):
    pass

@when('we implement {number:d} tests')
def step_impl(context, number):  # -- NOTE: number is converted into integer
    assert number > 1 or number == 0
    context.tests_count = number

@then('behave will test them for us!')
def step_impl(context):
    assert context.failed is False
    assert context.tests_count >= 0

Run behave:

$ behave
Feature: Showing off behave # features/example.feature:2

  Scenario: Run a simple test          # features/example.feature:4
    Given we have behave installed     # features/steps/example_steps.py:4
    When we implement 5 tests          # features/steps/example_steps.py:8
    Then behave will test them for us! # features/steps/example_steps.py:13

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined

Now, continue reading to learn how to get the most out of behave. To get started, we recommend the tutorial and then the feature testing language and api references.

More Information

behave.example's People

Contributors

dsm23 avatar jenisys avatar kotiesmit avatar renovate-bot avatar renovate[bot] avatar suud avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

behave.example's Issues

pavement.py missing 'import sys' (Version 1.2.4dev)

I was following the README.rst instructions and when I ran:

paver clean

I got a NameError for the line:

sys.path.insert(0, ".")

in the pavement.py file. Adding import sys before the call allowed paver to run.

Error during run test with paver

Is it ok to have errors during run example tests?
(Python 3.5, behave 1.2.5)

Can I run test with some python script launcher , without paver magic ? :)

I just run example and see error.

C:\Users\USER\Desktop\behave.example-master\behave.example-master>d:\P4\deploy\python35\python.exe bin\pavercmd.py test
---> pavement.test
---> pavement.init
---> pavement.behave_test
bin\behave -f progress --tags=-@xfail features/
Traceback (most recent call last):
  File "C:\Users\USER\Desktop\behave.example-master\behave.example-master\bin\behave_run.py", line 14, in <module>
    from behave_ext.formatter import pretty2
  File "C:\Users\USER\Desktop\behave.example-master\behave.example-master\lib\python2\behave_ext\formatter\pretty2.py", line 6, in <module>
    from behave_ext.terminal import select_terminal_class, get_terminal_size
  File "C:\Users\USER\Desktop\behave.example-master\behave.example-master\lib\python2\behave_ext\terminal\__init__.py", line 45, in <module>
    ColoredTerminalWriter = select_terminal_class(colored=True)
  File "C:\Users\USER\Desktop\behave.example-master\behave.example-master\lib\python2\behave_ext\terminal\__init__.py", line 37, in select_terminal_class
    return winterm.Terminal
AttributeError: 'module' object has no attribute 'Terminal'


Captured Task Output:
---------------------

---> pavement.test
---> pavement.init
---> pavement.behave_test
bin\behave -f progress --tags=-@xfail features/

Build failed running pavement.test: Subprocess return code: 1

Command Line Option for Generation Python Template Code?

If I only put .feature files under features folder but no .py files provider in steps folder, when I run behave, it will generate a template python code at the end of the output. Does behave have an option to generate this template python code?

Problem with running predefined data types example

Hi,
I would like to ask about problem with running predefined data types example.

I was trying to start this example, but I'm getting NotImplementedError exception and also PyCharm is reporting regex parsing error (separate topic here: maximehamm/tzatziki#13).

image

I'm starting the tests with below command:

behave "PATH  TO TESTS" --no-capture

Am i missing some obvious configuration?

PyCharm version: 2021.02.01 (Professional Edition)
System: Ubuntu 20.04.2 LTS
behave package version: 1.2.6

NameError: name 'behave_run' is not defined

On Windows 10 running "invoke test" after fixing invoke.yml to run on windows

run:
    echo: true
    pty: false
    shell: C:\Windows\System32\cmd.exe

I get the following:

(.venv_py) C:\Development\behave\behave.example>invoke test
�[1;37mc:\development\behave\behave.example\.venv_py\scripts\python.exe bin/behave -f progress  features�[0m
Traceback (most recent call last):
  File "bin/behave", line 1, in <module>
    behave_run.py
NameError: name 'behave_run' is not defined

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

pip_requirements
py.requirements/basic.txt
  • behave v1.2.7.dev1
  • PyHamcrest <2.0.0
  • PyHamcrest >= 2.0.2
  • traceback2 >= 1.4.0
  • parse >= 1.18.0
  • parse_type >= 0.5.2
py.requirements/docs.txt
  • sphinx >=2.0
  • sphinx_bootstrap_theme >= 0.6.0
  • sphinxcontrib-programoutput >=0.8,<0.10.0
  • sphinxcontrib-ansi JE_v0.7.0
  • sphinx-intl >= 0.9.11
tasks/py.requirements.txt
  • invoke ==1.4.1
  • six ==1.16.0
  • path >= 13.1.0
  • path.py >= 11.5.0
pip_setup
setup.py
  • behave >=1.2.6
  • PyHamcrest >=1.9
  • parse >=1.8.2
  • parse_type >=0.4.2
  • six >=1.11.0

  • Check this box to trigger a request for Renovate to run again on this repository

Line 23,24 & 25 causes an error.

Hi,

Thank you for your example this helped me get started on configuring my pylint.

I wanted to let you know the statement # path. You may set this option multiple times. is no longer true in my instance of python3

pylint ~/Documents/mymodule.py 
Traceback (most recent call last):
  File "/anaconda3/bin/pylint", line 11, in <module>
    sys.exit(run_pylint())
  File "/anaconda3/lib/python3.6/site-packages/pylint/__init__.py", line 16, in run_pylint
    Run(sys.argv[1:])
  File "/anaconda3/lib/python3.6/site-packages/pylint/lint.py", line 1301, in __init__
    linter.read_config_file()
  File "/anaconda3/lib/python3.6/site-packages/pylint/config.py", line 654, in read_config_file
    parser.read_file(fp)
  File "/anaconda3/lib/python3.6/configparser.py", line 718, in read_file
    self._read(f, source)
  File "/anaconda3/lib/python3.6/configparser.py", line 1092, in _read
    fpname, lineno)
**configparser.DuplicateOptionError: While reading from '/Users/jkirchoff/.pylintrc' [line 24]: option 'ignore' in section 'MASTER' already exists**

error in behave setup command: use_2to3 is invalid.

Elsewhere I found this as a fix...

pip install "setuptools<58.0.0"

But then I got a different error - see 2nd listing below.

I then used this hack : https://stackoverflow.com/questions/72659999/chatterbot-module-error-attributeerror-module-collections-has-no-attribute to change the package of HAshtable to .abc.

I use ...
Python 3.10.12
pip 24.0
.. but hacked up as above (Grrrrr python ecosystem, why can't it just work!!!)

=========

(.venv) john@JohnLenovo14Pro:~/work/behave.example$ pip install -r py.requirements/all.txt
Collecting git+https://github.com/behave/[email protected] (from -r py.requirements/basic.txt (line 11))
Cloning https://github.com/behave/behave.git (to revision v1.2.7.dev1) to /tmp/pip-req-build-lse6vqsl
Running command git clone --filter=blob:none --quiet https://github.com/behave/behave.git /tmp/pip-req-build-lse6vqsl
Running command git checkout -q 4e73cabf1b2445b3c1ab6b3aed14424d32d140ac
Resolved https://github.com/behave/behave.git to commit 4e73cabf1b2445b3c1ab6b3aed14424d32d140ac
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error

× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [16 lines of output]
/home/john/work/behave.example/.venv/lib/python3.10/site-packages/setuptools/dist.py:472: SetuptoolsDeprecationWarning: Invalid dash-separated options
!!

          ********************************************************************************
          Usage of dash-separated 'upload-dir' will not be supported in future
          versions. Please use the underscore name 'upload_dir' instead.

          By 2024-Sep-26, you need to update your project and remove deprecated calls
          or your builds will no longer be supported.

          See https://setuptools.pypa.io/en/latest/userguide/declarative_config.html for details.
          ********************************************************************************

  !!
    opt = self.warn_dash_deprecation(opt, section)
  error in behave setup command: use_2to3 is invalid.
  [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

======

(.venv) john@JohnLenovo14Pro:~/work/behave.example$ invoke cleanup
Traceback (most recent call last):
File "/home/john/work/behave.example/.venv/bin/invoke", line 8, in
sys.exit(program.run())
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/program.py", line 373, in run
self.parse_collection()
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/program.py", line 465, in parse_collection
self.load_collection()
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/program.py", line 702, in load_collection
self.config.load_project()
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/config.py", line 749, in load_project
self._load_file(prefix="project", merge=merge)
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/config.py", line 888, in _load_file
self._set(data, loader(filepath))
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/config.py", line 908, in _load_yaml
return yaml.load(fd)
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/init.py", line 72, in load
return loader.get_single_data()
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/constructor.py", line 37, in get_single_data
return self.construct_document(node)
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/constructor.py", line 46, in construct_document
for dummy in generator:
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/constructor.py", line 398, in construct_yaml_map
value = self.construct_mapping(node)
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/constructor.py", line 204, in construct_mapping
return super().construct_mapping(node, deep=deep)
File "/home/john/work/behave.example/.venv/lib/python3.10/site-packages/invoke/vendor/yaml3/constructor.py", line 126, in construct_mapping
if not isinstance(key, collections.Hashable):
AttributeError: module 'collections' has no attribute 'Hashable'

How do we use behave with TestInfra?

What is the best way to leverage behave with another framework that is pytest based? I am trying to leverage Behave with TestInfra. The goal is to verify infrastructure using BDD syntax.

Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.