BDD base project: Python + Behave

Overview

code style: prettier

BDD base project: Python + Behave

Basic example of using Python with Behave (BDD). This Gherkin example includes:

  • Basic Scenario
  • Scenario Outline
  • Tagged tests

Table of contents

Get started

Installation

pip3 install -r requirements.txt

on Ubuntu 20.04 (pyvirtualdisplay requirements, we use pyvirtualdisplay to avoid Cloudflare errors in headless mode):

sudo apt-get install xvfb xserver-xephyr tigervnc-standalone-server xfonts-base

How to run the tests

Running tests

behave
2 features passed, 0 failed, 0 skipped
6 scenarios passed, 0 failed, 0 skipped
30 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m50.056s
  • ./reports/ folder:

    Output

Running tests and generate Allure report

behave -f allure -o reports/allure_report/
  • ./reports/ folder:

    Output

Open Allure report

Note: allure is required.

allure serve reports/allure_report/

HTML report:

Output

Running tagged tests

Running tagged smoke tests

behave --tags=smoke

Running using customized tags

behave --tags='
   
    '
   

more details: running-tagged-tests

Change Browser

edit behave.ini:

...

[behave.userdata]
browser=firefox  # <- CHANGE HERE - Available options: firefox | chrome

...

Change Headless mode

edit behave.ini:

...

[behave.userdata]
headless = true  # <- CHANGE HERE - Available options: true | false

...

Static code analysis tools

Find Problems

Checkers statically analyzes the code to find problems.

bash code_checkers.sh  # run pylint, prospector, black and isort

Tools used:

  • pylint: Pylint is a Python static code analysis tool which looks for programming errors, helps enforcing a coding standard, sniffs for code smells and offers simple refactoring suggestions.

  • black: Black is the uncompromising Python code formatter.

  • isort: Python utility / library to sort imports alphabetically, and automatically separated into sections and by type.

  • prospector: Prospector is a tool to analyse Python code and output information about errors, potential problems, convention violations and complexity.

    Tools executed by Prospector:

    • bandit: Bandit is a tool designed to find common security issues.
    • dodgy: It is a series of simple regular expressions designed to detect things such as accidental SCM diff checkins, or passwords or secret keys hard coded into files.
    • mccabe: Complexity checker.
    • mypy: Mypy is an optional static type checker for Python.
    • pep257: pep257 is a static analysis tool for checking compliance with Python PEP 257.
    • pep8: pep8 is a tool to check your Python code against some of the style conventions in PEP 8.
    • pyflakes: Pyflakes analyzes programs and detects various errors.
    • pyroma: Pyroma is a product aimed at giving a rating of how well a Python project complies with the best practices of the Python packaging ecosystem, primarily PyPI, pip, Distribute etc, as well as a list of issues that could be improved.

Testing

We use tox to validate changes on linux OS (headless mode):

tox

output:

...

2 features passed, 0 failed, 0 skipped
6 scenarios passed, 0 failed, 0 skipped
30 steps passed, 0 failed, 0 skipped, 0 undefined
Took 0m43.177s
_____________________________________________ summary _____________________________________________
  code_checkers: commands succeeded
  py36: commands succeeded
  py37: commands succeeded
  py38: commands succeeded
  py39: commands succeeded
  congratulations :)

to validate changes for a particular Python version (36, 37, 38 or 39), you can do:

tox -e py36

License

MIT

Changelog

  • 1.0.0 - Initial release.
You might also like...
🛠️ Learn a technology X by doing a project  - Search engine of project-based learning
🛠️ Learn a technology X by doing a project - Search engine of project-based learning

Learn X by doing Y 🛠️ Learn a technology X by doing a project Y Website You can contribute by adding projects to the CSV file.

Covid-19-Trends - A project that me and my friends created as the CSC110 Final Project at UofT

Covid-19-Trends Introduction The COVID-19 pandemic has caused severe financial s

The-White-Noise-Project - The project creates noise intentionally

The-White-Noise-Project High quality audio matters everywhere, even in noise. Be

A example project's description is a high-level overview of why you’re doing a project.

A example project's description is a high-level overview of why you’re doing a project.

 Audio2Face - a project that transforms audio to blendshape weights,and drives the digital human,xiaomei,in UE project
Audio2Face - a project that transforms audio to blendshape weights,and drives the digital human,xiaomei,in UE project

Audio2Face - a project that transforms audio to blendshape weights,and drives the digital human,xiaomei,in UE project

this is a basic python project that I made using python

this is a basic python project that I made using python. This project is only for practice because my python skills are still newbie.

A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.
A command-line utility that creates projects from cookiecutters (project templates), e.g. Python package projects, VueJS projects.

Cookiecutter A command-line utility that creates projects from cookiecutters (project templates), e.g. creating a Python package project from a Python

Paprika is a python library that reduces boilerplate. Heavily inspired by Project Lombok.
Paprika is a python library that reduces boilerplate. Heavily inspired by Project Lombok.

Image courtesy of Anna Quaglia (Photographer) Paprika Paprika is a python library that reduces boilerplate. It is heavily inspired by Project Lombok.

Owner
eccanto
eccanto
A script where you execute a script that generates a base project for your gdextension

GDExtension Project Creator this is a script (currently only for linux) where you execute a script that generates a base project for your gdextension,

Unknown 11 Nov 17, 2022
A code base for python programs the goal is to integrate all the useful and essential functions

Base Dev EN This GitHub will be available in French and English FR Ce GitHub sera disponible en français et en anglais Author License Screen EN ???? D

Pikatsuto 1 Mar 7, 2022
Python script to autodetect a base set of swiftlint rules.

swiftlint-autodetect Python script to autodetect a base set of swiftlint rules. Installation brew install pipx

Jonathan Wight 24 Sep 20, 2022
Construção de um jogo Dominó na linguagem python com base em algoritmos personalizados.

Domino (projecto-python) Construção de um jogo Dominó na linguaguem python com base em algoritmos personalizados e na: Monografia apresentada ao curso

Nuninha-GC 1 Jan 12, 2022
A program made in PYTHON🐍 that automatically performs data insertions into a POSTGRES database 🐘 , using as base a .CSV file 📁 , useful in mass data insertions

A program made in PYTHON?? that automatically performs data insertions into a POSTGRES database ?? , using as base a .CSV file ?? , useful in mass data insertions.

Davi Galdino 1 Oct 17, 2022
Yunqi Chen 7 Oct 30, 2022
Implent of Oracle Base line and Lea-3 Baseline

Oracle-Baseline Implent of Oracle Base line and Lea-3 Baseline Oracle Oracle : This model is used to obtain an oracle with a greedy algorithm similar

Andrew Zeng 2 Nov 12, 2021
Converts a base copy of Pokemon BDSP's masterdatas into a more readable and editable Pokemon Showdown Format.

Showdown-BDSP-Converter Converts a base copy of Pokemon BDSP's masterdatas into a more readable and editable Pokemon Showdown Format. Download the lat

Alden Mo 2 Jan 2, 2022
Adansons Base is a data management tool that organizes metadata of unstructured data and creates and organizes datasets.

Adansons Base is a data management tool that organizes metadata of unstructured data and creates and organizes datasets. It makes dataset creation more effective and helps find essential insights from training results and improves AI performance.

Adansons Inc 27 Oct 22, 2022
edgetest is a tox-inspired python library that will loop through your project's dependencies, and check if your project is compatible with the latest version of each dependency

Bleeding edge dependency testing Full Documentation edgetest is a tox-inspired python library that will loop through your project's dependencies, and

Capital One 16 Dec 7, 2022