ashikkumar23 / gherkin-bdd-api-test-framework

"A repository featuring a BDD-based automation framework for efficient API testing using the user-friendly Gherkin syntax and BDD principles."

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

API Automation Framework

Actions Status

API Automation Framework using pytest and pytest-bdd

πŸš€ Description:

Automated CRUD (i.e., POST, GET, PUT, DELETE) operations using pytest and pytest-bdd

πŸš€ Prerequisites:

requests pytest pytest-bdd

πŸš€ Installation Steps:

In order to get the tests to run locally, you need to install the following pieces of software.

NOTE: All commands shall be executed from Automation Project root directory: ../[PROJECT_DIR]/tests/

MacOS

  • Install Homebrew with /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  • Install Pyenv with brew install pyenv, this is a python version manager.
  • Add the following to ~/.bash_profile
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
export PATH="$PYENV_ROOT/shims:$PATH"
export PATH="$PYENV_ROOT/completions/pyenv.bash:$PATH"
  • Install python 3.8.13 with pyenv install 3.8.13
  • Set python version 3.8.13 to be used globally with pyenv global 3.8.13
  • Install virtualenv with python3 -m pip install --user virtualenv
  • Create new virtual env with python3 -m virtualenv .venv
  • Activate new virtual env with source ./.venv/bin/activate
  • Install all project dependencies with pip install -r requirements.txt --use-pep517
  • Check the python version used with which python, which shall be [PROJECT_DIR]/tests/.venv/bin/python.

Windows / Linux

  • Install GitBash
  • Uninstall any previous python version
  • Install python 3.8.13 using the official installation file
  • Install all project dependencies with pip install -r requirements.txt --use-pep517

πŸš€ Project Structure:

bdd-gherkin-test-automation-framework/
β”œβ”€ .github/
β”‚  β”œβ”€ workflows/
β”‚  β”‚  β”œβ”€ ci.yml
β”œβ”€ tests/
β”‚  β”œβ”€ data/
β”‚  β”‚  β”œβ”€ post_payload_1.json
β”‚  β”‚  β”œβ”€ post_payload_2.json
β”‚  β”‚  β”œβ”€ put_payload_1.json
β”‚  β”‚  β”œβ”€ put_payload_2.json
β”‚  β”œβ”€ features/
β”‚  β”‚  β”œβ”€ sample.feature
β”‚  β”œβ”€ lib/
β”‚  β”‚  β”œβ”€ terminal_report.py
β”‚  β”œβ”€ step_definitions/
β”‚  β”‚  β”œβ”€ test_assertions.py
β”‚  β”‚  β”œβ”€ test_common.py
β”‚  β”‚  β”œβ”€ test_sample.py
β”‚  β”œβ”€ utils/
β”‚  β”‚  β”œβ”€ __init__.py
β”‚  β”‚  β”œβ”€ custom_exceptions.py
β”‚  β”‚  β”œβ”€ logger_config.py
β”‚  β”‚  β”œβ”€ utils.py
β”‚  β”œβ”€ .env
β”‚  β”œβ”€ .gitignore
β”‚  β”œβ”€ conftest.py
β”‚  β”œβ”€ pytest.ini
β”‚  β”œβ”€ requirements.txt
β”œβ”€ LICENSE
β”œβ”€ README.md

πŸš€ Test Execution:

  • Fork the repository bdd-gherkin-api-test-automation-framework
  • Clone the repository via HTTPS git clone https://github.com/<your_github_username>/bdd-gherkin-api-test-automation-framework.git or via SSH git clone git@github.com:<your_github_username>/bdd-gherkin-api-test-automation-framework.git
  • Open Pycharm (or any IDE) > File > Open > Open the project where the repository is located (i.e., ../bdd-gherkin-test-automation-framework/tests)
  • Run the command: python -m pytest -v --gherkin-terminal-reporter --reruns 1 --reruns-delay 1 --tags="automated" -s --color="yes" in Terminal

πŸš€ Pycharm Edit Configuration:

  • Go to Edit Configurations...
  • Add New Configuration (+ sign) > Python tests > pytest
  • Provide Target Script path and Working directory (i.e., ../bdd-gherkin-test-automation-framework/tests)
  • Select the required Python interpreter
  • And, Additional Arguments: -v --gherkin-terminal-reporter --reruns 1 --reruns-delay 1 --tags="automated" --color="yes"

About

"A repository featuring a BDD-based automation framework for efficient API testing using the user-friendly Gherkin syntax and BDD principles."

License:GNU General Public License v3.0


Languages

Language:Python 87.0%Language:Gherkin 13.0%