Skip to content

A Rest-API test automation framework which is build on the top of Python language using PyTest Framework.

Notifications You must be signed in to change notification settings

kalydrae/api-testing-python

 
 

Repository files navigation

PyRestAPITest

This application is built to do REST API testing using python scripts along with the use of Pytest module as our testing framework.

API being tested: restful-booker

License

Languages, libraries and tools used

Above Features are used to make code simple, generic, understandable, clean and easily maintainable for future development. Above features inlcude as well Allure reporting for test reporting

Installation

Install the dependencies and start the testing.

Install Pytest:

pip install -U pytest

Install Requests:

pip install requests

Install Json Path:

pip install jsonpath

Install Allure with Pytest:

pip install allure-pytest

Next download the latest allure package zip from allure-framework GitHub repo

  • Unzip the downloaded zip file
  • Copy the path till bin
  • Add it to the path environment variable
  • Open the terminal and run

allure --version

Automated tests

To run a test, you can simply write the following command on Terminal:

pytest

To run and get details of all the executed test, you can simply write the following command on Terminal:

pytest -rA

To run and generate full HTML details report of all the executed test, you can simply write the following commands on Terminal:

But first install Pytest-HTML by writing the following command on Terminal

pip install pytest-html

Then write the following command on Terminal

pytest --html==YOUR_REPORT_FILE_NAME.html

To see the reports, open the Project window, and then right-click then click on refresh then right-click on StationReport.html to open the file on the default browser.



To run and generate Allure reports

In the project directory generate a folder to save allure reports; use the command below to automatically generate this

allure generate

This will create a folder named allure-report in your project directory

Now you can run your tests with pytest runner by specifying the directory path to save your allure report

pytest --alluredir=allure-report/

Once test execution completes, all the test results would get stored in allure-report directory

The allure report can be viewed in the browser with the command

allure serve allure-report/

Link to allure pytest

Prerequisites

  • Python
  • Any IDE

Built With

  • Python - Language used to build the application.
  • Pycharm - The IDE for writing Automation Test Scripts

About

A Rest-API test automation framework which is build on the top of Python language using PyTest Framework.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 82.3%
  • CSS 17.7%