项目作者: ashikkumar23

项目描述 :
API Automation Framework using pytest and pytest-bdd
高级语言: Python
项目地址: git://github.com/ashikkumar23/bdd-gherkin-api-test-automation-demo.git
创建时间: 2020-07-28T06:49:42Z
项目社区:https://github.com/ashikkumar23/bdd-gherkin-api-test-automation-demo

开源协议:MIT License

下载


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
  1. export PYENV_ROOT="$HOME/.pyenv"
  2. export PATH="$PYENV_ROOT/bin:$PATH"
  3. export PATH="$PYENV_ROOT/shims:$PATH"
  4. 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:

  1. bdd-gherkin-test-automation-framework/
  2. ├─ .github/
  3. ├─ workflows/
  4. ├─ ci.yml
  5. ├─ tests/
  6. ├─ data/
  7. ├─ post_payload_1.json
  8. ├─ post_payload_2.json
  9. ├─ put_payload_1.json
  10. ├─ put_payload_2.json
  11. ├─ features/
  12. ├─ sample.feature
  13. ├─ lib/
  14. ├─ terminal_report.py
  15. ├─ step_definitions/
  16. ├─ test_assertions.py
  17. ├─ test_common.py
  18. ├─ test_sample.py
  19. ├─ utils/
  20. ├─ __init__.py
  21. ├─ custom_exceptions.py
  22. ├─ logger_config.py
  23. ├─ utils.py
  24. ├─ .env
  25. ├─ .gitignore
  26. ├─ conftest.py
  27. ├─ pytest.ini
  28. ├─ requirements.txt
  29. ├─ LICENSE
  30. ├─ 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"