Skip to content

AdrianMacovei/ApiTestingProject

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hi 👋, I'm Adrian

A passionate automation tester and python developer from Romania

adrianmacovei

Connect with me:

adrian-macovei-4b3a23169 adrian_m105

Languages and Tools:

python selenium behave postman git html5 mysql java jira

API Testing Project

In the current project I test the Simple Book API using two different approach:

  • Testing API with Postman (dedicated GUI application for API testing purpose) and JavaScript for writing tests.
  • Testing API with Python and it’s library Requests (dedicated Python library for API testing)

Simple Book API testing with Postman

Prerequisites

To run the collection need to:

Run the test in the Postman collection with steps billow:

  • Create a folder for this project

  • Clone the repo on your divice using in terminal command git clone https://github.com/AdrianMacovei/API-Testing-Project

  • Open Postman

  • Follow steps in video: Postman video

Simple Book API testing with Python/Requests

Prerequisites

To run the Python code need to:

Run test in IDE with steps bellow:

  • Create a folder for the project and clone the repo (see in video above)

  • Follow the steps in the video to run the test: Pycharm video

  • If want to create html report run next command in the terminal pytest --html=report.html --self-contained-html

Project structure

API testing with Python and requests has two main parts:

  • TestCase folder where is the api_test.py file that is the host file for all the test in the project.
  • UserDataAndApiMethods folder has two .txt files that are connected to the api_methods_config and help to save the data on disk (persistence), data like authentication toke and current user data (name and email).

Tests results

In this project, I create a number of 36 tests that test different functionality of the API. Form the total number 6 failed and 30 passed. Based on the test result I can make the following recommendations for developers of the API to increase the quality of the product:

  • When sending a get request to the endpoint /books with limit 0 and string value in it the API accepts the values and return all books available. There in my opinion, will be better a 4xx response with the return message error "Invalid limit value".

  • I tried to change an order attribute id and quantity using a patch request to the endpoint /orders/order_id and the response status code was 204 No content the same status code was used to delete the order request and change the customer name of the order. In my opinion, the code should be different because the last two mentioned (delete and change customer name) make a change in the database but the first two (change quantity and id) don't (value remain the same after I tried to change it). A recommendation is for all the attributes of order that can't be modified to return a 4xx code with some error message. Even for the delete and customer name update will be great to return some content that informs the person who uses the API that his request makes the change in the data (ex: {"status":"order deleted"} or {"status":"customer name updated"}).

  • Now the order quantity attribute can't be changed but will be a good update for the API if in the future will offer this possibility after that an order can contain for example more than one book of the same type.

  • Tried to test if ordering more than the available number of a book will activate some error message and I find that the server doesn’t update the book quantity accordingly with the number of orders for the book. This can be disastrous for a business for example because will go to a situation when the client’s order can’t be honoured just because the stock is not updated properly. The recommendation is to make the server update the book quantity accordingly with the number of orders and to change the value of the attribute available to False when the stock reaches the value of zero.

  • Finally, I find that in the authentication part the API accepts integer data type in the customer name, can be a good practice if will be changed to accept only string data type.

alt text

About

API testing in two different ways Postman/JavaScript and Python/Requests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages