API Automation Framework using pytest
and pytest-bdd
Automated CRUD (i.e., POST
, GET
, PUT
, DELETE
) operations using pytest
and pytest-bdd
requests
pytest
pytest-bdd
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/
- 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
.
- 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
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
- 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 SSHgit clone [email protected]:<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"
inTerminal
- Go to
Edit Configurations...
- Add
New Configuration
(+
sign) >Python tests
>pytest
- Provide
Target Script path
andWorking 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"