DEV Community

Fleek It Solutions
Fleek It Solutions

Posted on

API automation using Python and open-source framework

python-project.html

Writing test case
As now you already have setup your python project with Pycharm, let’s create a new python file where we will add our test cases.

Please create a new python file in your project. Let’s name it “test_apitest.py”. Notice the “test_” in your file name. This is as per the rules for PyTest. We will be running our tests using Python’s inbuilt testing framework called PyTest. PyTest picks all those python files in your project which start with “test_” for test execution.

In “test_apitest.py” file, our first statement would be :

import requests
“requests” is python’s inbuilt module which is used to send http requests to a server. We will be using this module to send requests to our API and record the response.

Now, for this tutorial we will be using a sample test API available online : https://reqres.in/api
We will be sending requests to the endpoints defined in this API.

Read more on
https://www.fleekitsolutions.com/api-automation-using-python/

Top comments (0)