API Testing Archives - Codoid
Select Page

Blog

Category Selected: API Testing

6 results Found

API Testing
API Testing

What Is API Testing?

API Testing

Jenkins Python API Endpoints

API Testing
API Testing

People also read

OTT Testing

How to Perform Android TV Automation Testing using Appium?

Accessibility Testing
Blog

The Importance of QA Testing in eLearning Development

The Complete Guide to Perform Manual REST API Testing Using Postman

The Complete Guide to Perform Manual REST API Testing Using Postman

Postman is one of the most popular software testing tools which is used for API testing. Postman is widely used by both software testers and developers for testing as it is easy to integrate with Continuous Integration (CI) & Continuous Development Pipelines. Postman sends an API request to the webserver and receives the response. As one of the leading QA companies, we have been doing our manual Rest API testing using Postman whenever it was deemed necessary. So if you are someone who is looking for a complete guide that explains everything from what is REST API to how it works to how it can be manually tested using Postman, you will definitely find this blog useful.

API (Application Programming Interface)

An API is a set of defined rules that enables computers or applications to communicate with one another. APIs sit between an application and the webserver and acts as an intermediary that processes data transfer between systems.

What is REST API?

  • REST API (Representational State Transfer Application Program Interface) is an architectural style that allows the software to communicate with other software on the same device or over a network.
  • REST APIs communicate via HTTP requests to perform standard database functions like creating, reading, updating, and even deleting records (also known as CRUD) within a resource.

Why REST API?

These are the major reasons as to why we choose REST API over the other options. REST API is

1. Easy to Learn & Implement

2. Easy to Build & Maintain

3. Scalable

4. Cacheable

5. Flexible and Portable

How does REST APIs work?

As stated earlier, REST APIs use HTTP requests for their communication. HTTP works as a request-response protocol between a client and server and enables client-to-server communication. For example, your web browser can be considered as the client, and the application on the computer that hosts the website can be termed as the server. So if your browser (client) submits an HTTP request to the server, the server will return a response that contains the status information of the request and the requested content if any were requested.

Common HTTP methods (CRUD commands) used in REST API:

Most of these commands have very straightforward names that make them self-explanatory. So once you have been introduced to them, it will be very easy for you to remember.

  • GET – The GET method can be used to extract information from the given server using a given URI. It is worth noting that when you use the GET request, it should only extract the data and not have any other effect on the data. So no Payload/Body is required.
  • POST – As the name suggests, a POST request is used to send data to the server. Data like customer information, files, and so on can be sent using HTML forms.

  • PUT – Using PUT, you will be able to replace all the current representations of the target resource with the uploaded content.
  • DELETE – It can be used to remove all the current representations of the target resource given by a URI.

There are other CRUD commands like patch, copy, and so on as well. So once you are thorough with these basics, you can explore them.

API Contract

We have seen the basics of REST API that you will need to know. There are also a few basics of Postman that you should be familiar with. But before we can move forward, we have to explore a few aspects of the API contract as you’d have to know the following information to perform manual REST API testing using Postman.

Endpoint:

It is the address where the API is hosted on the Server. An End Point Request URL can be constructed as below
Base URL/resource/(Query/Path)Parameters

Resources:

They represent the API/Collection that can be accessed from the Server. We have listed a few common examples below to help you understand better.

  • Google.com/maps
  • google.com/search
  • google.com/images

Here maps, search and images are the resources of Google.com which is the Base URL.

Path Parameters:

Path parameters are the variable parts of a URL path. They are generally used to point to a specific resource within a collection in the same way how a user is identified by ID.

Example for Path Parameters:

  • https://www.google.com/Images/1123343
  • https://www.google.com/docs/1123343
  • https://amazon.com/orders/112

Here 1123343, and 112 are the parameters

Query Parameters:

Query Parameters are primarily used to sort or filter the resources. They can be identified with ”?” (A Question Mark). You’ll be able to identify them once you see a few examples.

  • https://amazon.com/orders?sort_by=07/09/2021
  • https://www.google.com/search?q=newyork&oq=newyork&aqs=chrome..69i57j0l7.2501j0j7&sourceid=chrome&ie=UTF-8

Here orders and search are your resources and they are sorted and filtered by the query parameter that is followed by the “?”.

Headers/Cookies:

Headers represent the meta-data associated with the API request and its response. In layman’s terms, it will be used to send additional details to the API for processing our request. An example of it would be the authorization details.

Sample API Contract for Basic CRUD commands:

Apart from these values, we would also have to know about the HTTP method in use, the body, content types of the parameter and response (either Application or JSON), and also the response value. You will get a clear idea of these aspects when we see a few examples.

1. Request to Log in – Successful

Parameters

Base URL: https://reqres.in

Request : /api/login

Request Type: POST

Body :

{
    "email": "[email protected]",
    "password": "cityslicka"
}

Parameter Content Type: application/json

Responses:

Response Content Type: application/json

Response Code : 200

Description : OK

Response Value :

{
    "token": "QpwL5tke4Pnpja7X4"
}
2. Request to Get a List of Users

Parameters

Base URL: https://reqres.in

Request: /api/users

Request Type: GET

Responses:

Response Content Type: application/json

Response Code : 200

Description : OK

Response Value :

{
    "page": 1,
    "per_page": 6,
    "total": 12,
    "total_pages": 2,
    "data": [
        {
            "id": 1,
            "email": "[email protected]",
            "first_name": "George",
            "last_name": "Bluth",
            "avatar": "https://reqres.in/img/faces/1-image.jpg"
        },
        {
            "id": 2,
            "email": "[email protected]",
            "first_name": "Janet",
            "last_name": "Weaver",
            "avatar": "https://reqres.in/img/faces/2-image.jpg"
        },
        {
            "id": 3,
            "email": "[email protected]",
            "first_name": "Emma",
            "last_name": "Wong",
            "avatar": "https://reqres.in/img/faces/3-image.jpg"
        },
        {
            "id": 4,
            "email": "[email protected]",
            "first_name": "Eve",
            "last_name": "Holt",
            "avatar": "https://reqres.in/img/faces/4-image.jpg"
        },
        {
            "id": 5,
            "email": "[email protected]",
            "first_name": "Charles",
            "last_name": "Morris",
            "avatar": "https://reqres.in/img/faces/5-image.jpg"
        },
        {
            "id": 6,
            "email": "[email protected]",
            "first_name": "Tracey",
            "last_name": "Ramos",
            "avatar": "https://reqres.in/img/faces/6-image.jpg"
        }
    ],
    "support": {
        "url": "https://reqres.in/#support-heading",
        "text": "To keep ReqRes free, contributions towards server costs are appreciated!"
    }
}
3. Request to update user Information

Parameters

Base URL: https://reqres.in

Request : /api/users/{{User_ID}}

User_ID=2

Request Type: PUT

Body :

{
    "name": "morpheus",
    "job": "zion resident"
}

Parameter Content Type: application/json

Responses:

Response Content Type: application/json

Response Code : 200

Description : OK

Response Value :

{
    "name": "morpheus",
    "job": "zion resident",
    "updatedAt": "2021-10-05T19:20:33.979Z"
}
4. Request to Get a List of Users

Parameters

Base URL: https://reqres.in

Request : /api/users/{{User_ID}}

User_ID=2

Request Type: DELETE

Responses:

Response Content Type: application/json

Response Code : 204

Description : OK

Response Value :[]

Now that we have fully covered all the prerequisites when it comes to REST API, let’s see why we use test REST APIs and explore a few other prerequisites that will be required to perform Rest API testing using Postman.

Why Postman tool?

Postman is a simple GUI for sending HTTP requests and viewing its responses. It is built upon an extensive set of power tools, which are incredibly easy to use. Postman helps you perform a variety of functions and has a lot of useful functionalities as well.

  • Since Postman is accessible from anywhere, you have to just install it into the device and access it by logging into the account.
  • Your test suites will be more organized as Postman allows users to build collections for their API calls. Every set can create multiple requests and subfolders.
  • Using Postman, you’ll be able to test checkpoints with the verification of the successful HTTP response status that will be added to every API call.
  • Automation Testing becomes easier as several iterations of the tests can be performed by using the Collection Runner or Newman. So you can save a lot of time when performing repetitive tests.
  • As Postman makes it easy to create environments, you can design multiple environments and reduce the replication of tests as you’ll be able to use the same collection for a different setting.
  • The postman console helps to track what data is being retrieved makes it possible to effectively debug the tests.
  • The scope for collaboration is also high as you can import or export your collections & environments and share those files. You can also use a direct connection to share the collections.
  • Postman supports continuous integration as well.
  • You can use Postman by either downloading & installing their application or use their web version. It is a good option to have as both offer great performance.

How to create API requests in Postman

Learning how to create API requests is an integral part of learning how to perform manual REST API Testing using Postman. You will need to know more about the following 2 features to create an API request.

  • Workspace
  • Collections
Workspace in Postman:

Postman Workspaces acts as a common working area where you can group your API projects together and use API builder to define APIs or generate API elements. So they are helpful in organizing your API work better and collaborating with your teammates as well. Now let’s see how to create one.

Creating a Workspace in Postman:

Click on the Workspace dropdown in the header -> New Workspace -> WorkSpaceName (Type any workspace name you wish) -> Create Workspace.

Creating Workspace in Postman

Collections in Postman:
  • Postman Collections are Executable API Descriptions Postman’s collection folders make it easy to keep your API requests and elements organized.
  • Generate Collections from API schemas Generate a collection from an API schema to view and edit each request.
    Creating Collections in Postman:

Click on File -> New -> Collection -> CollectionName (Assign a Collection Name as you wish)

OR

Click Collection -> Create Collection Icon (+) -> CollectionName (Enter a Collection Name of your wish)

Creating Collections in Rest API testing using Postman

For testing the CRUD commands, we are going to use the information which is present in the above mention API contract.

Testing POST Request to Log in – Successful:

To make a POST request, click on the More option icon (…) -> Add Request -> Login User

Testing POST request to log in

1. From the Dropdown select POST

2. In the “Enter request URL” text box, type the following (URL): https://reqres.in/api/login

3. Click on Body Tab, select the ‘Raw’ radio button, and then the JSON format from the dropdown list.

4. In the text box, paste the Login Credentials:

{
 "email": "[email protected]",
 "password": "cityslicka
}

5. Click on the Send button

6. You should be able to see the below response:

Testing POST request response in Rest API Testing using Postman

7. Also, make sure to check for the correct status code here. In this case, you should get: ‘Status: 200’ as shown in the image below.

Correct Status Code in the response

Testing GET Request to Get the List of Users:

To make a GET request, you have to click on the More options icon (…) -> Add Request -> Request to Get List of Users (Assign any requested name you wish)

1. From the Dropdown list, select GET

2. Type the mentioned URL (https://reqres.in/api/users) in the “Enter request URL” text box.

3. Click on the Send button.

4. You’ll be able to see the below response:

Testing GET request response in Rest API Testing using Postman

5. Once again, check for the status code and see if it is ‘Status: 200’.

Correct Status Code in the GET response

Testing PUT Request to update user Information:

Same as above, you have to click on the More option Icon(…) ->Add Request -> Request to Update user Information (Enter any request name of your choice)

1. Click on ‘PUT’ from the dropdown list.

2. In the “Enter request URL” text box that appears, type this URL: https://reqres.in/api/users/2

3. Click on the ‘Body’ Tab, select the ‘Raw’ radio button, and then choose the JSON format from the dropdown.

4. Paste the Login Credentials in the text box:

{
    "name": "morpheus",
    "job": "zion resident"
}

5. Click on the ‘Send’ button

6. You will see the below response:

Testing PUT request response in Rest API Testing using Postman

7. Check if the status is shown as ‘200 OK’.

Correct Status Code in the PUT response

Testing DELETE Request to Remove Users from Database

Click on the More option Icon (…) -> Add Request -> Request to Get the list of Users (Enter any request name you wish)

1. From the Dropdown list of options, select ‘DELETE’.

2. Type this URL https://reqres.in/api/users in the “Enter request URL” text box.

3. Click on the ‘Send’ button

4. Check is you see the below response:

Testing DELETE request response in Rest API Testing using Postman

5. Check if ‘Status: 200 OK’ is visible as shown in the image below.

Correct Status Code in the DELETE response

Conclusion:

It is evident that the steps we saw for each request were almost identical to each other. So by now, you should have no trouble in performing Rest API testing using Postman in an effective way to ensure high quality. As a leading manual testing services provider, we have often used Postman for our manual testing projects. But Postman can also be used for automation testing with the help of Test scripts.

A Wall-to-Wall Postman Guide for API Testing

A Wall-to-Wall Postman Guide for API Testing

Postman is an API (Application Programming Interface) development tool that allows users to perform GET, POST, PUT, DELETE, and many other requests to the web service API. Postman allows you to manually test your APIs in both its desktop and web-based applications. However, it also has the ability to automate these tests by writing JavaScript assertions on your API endpoints. As one of the best QA companies, we always thrive on using the best tools for our projects, and Postman has become one of our go-to tools when it comes to API testing. So in this Postman Guide, we will be exploring how to perform the above said requests like Post, Request, and so on. But before we proceed further, let’s have a brief introduction to API testing.

What is API Testing?

API testing is a type of software testing where application programming interfaces (APIs) are tested to determine if they meet the expected functionality, reliability, performance, and security levels. It only concentrates on the business logic layer of the software architecture.

API Testing - Postman Guide

Some of the important components in Postman

  • Pre-Request Script:

Users will be able to write a script to manipulate the data being sent with the request. The pre-request script will run before the request is sent.

  • Tests:

This is the test editor where the users can configure the test cases that are being validated once the request has been fulfilled.

  • Environment:

The environment in postman is a set of key-value pairs which is used to set dynamic values.

  • Collections:

A group of requests will be displayed under collections, and it can be used to organize and keep track of related requests.

Postman Guide to create & run the First API Request:

First and foremost, we have to create a new workspace and click on the New option under ‘File’, and then select ‘Request’.

Creating API request and running in Postman Guide

Enter the name as ‘GET Request’ and then click on + NEW COLLECTION. Following which we will be able to assign a suitable name for the collection.

Once we click on Save, the collection name will be displayed with your API in it. Now that we have prepped everything, let’s make the first API call by following the below steps,

We have to enter the URL in the address bar and click on the ‘Send’ button to see the response.

The response will include details such as the status code, time, size, headers, and cookies alongside the Body.

Response Image

Status Code

So if you take a look at the above image, the HTTP status code is shown to be “200 OK”, which means that everything has worked as expected and that our request is successful.

Time

Right beside the status code, we can see that the time taken to complete the request is 509 ms.

Size

The other available parameter is the size of the requested data, we can see that size is mentioned to be 1.92 KB in the above image.

Note:If we hover the mouse over the time and response values, we will be able to view more details

To save this response, we can simply click on the ‘Save Response’ option.

As stated above, we can also see the body, which is an HTML file in the image. Clicking on the ‘Preview’ option under the body will enable us to view the body in HTML format.

We can click on ‘Cookies’ to view the session-related information and on ‘Headers’ to view other details such as date, content type details, etc.

So by following the above instructions, we have successfully made our first request! Now let’s find out how to send a post request in Postman.

Postman Guide to send a Post Request:

Post is one of the HTTP methods that can be used to add new resources like a webpage and so on. So if we want to create and add a new user to the database, we can utilize the Post request. Likewise, we can also use Post requests for form submissions, authentication requests, and so on.

Let’s see how Post request works:

In Postman, we have an endpoint that responds back whenever we send a request. So, now we are going to send a particular key-value pair in the JSON format to a server.

First, we have to set the HTTP Method to POST.

Next, we have to mention the URL in the address bar.

In the Body tab of the request editor, we should select the ‘Raw’ option and then select JSON from the dropdown list.

We have chosen Raw with JSON as it is one of the most commonly used Post Requests.

So enter the REQUEST in the Body and click on ‘Send’.

Post Request working - Postman Guide

We can see that the user has been created in the above image. In addition to that, we also have the same type of information that we saw earlier that includes status code, time, and so on.

But this time around, we have the status code displayed as 201, which implies that the request has been created.
Click on ‘Save’ to save this request.

‘POST REQUEST’ can be used to add a set of data into the server database. But it is crucial to make sure that the fields are filled with the correct data type, as any incorrect data will result in a 400 Bad Request.

Postman Guide to send a DELETE Request:

Previously, we saw how to send a post request in which we created a user and sent a body. Now let’s see how we can delete a request in Postman. We can use the DELETE HTTP Method to delete an existing record of a user in a database. The expected response in the Status for this is 204.

So primarily, we would have to set the HTTP Method to DELETE, then mention the URL in the address bar, and also mention the final endpoint.

Once the above actions have been completed, we can go ahead and click on ‘Send’.

Expected Report

So as expected, we have the Status Code shown as 204, which denotes that the particular resource has been deleted.

But what if the user has some additional parameters? We can pass query parameters and add them to the body section for deleting those resources as well.

Collections

Collections are nothing but a group of requests grouped into a folder. The simplest example of this would be the way we organize the files on our computers or mobile phones. Let’s say we have multiple files of different formats like text files, audio files, video files, etc. We most probably would create new folders and segregate all the files based on their format.

In the same way, we can create different groups using POSTMAN, and each group can have its own type of request. In addition to having the option to create a collection, we will also be able to share this collection with the team members and encourage healthy collaboration. The other advantage is that since we can share the collection, we will also be able to perform various actions like assigning roles, documentation, mock servers, monitors, etc.

Postman Guide to create a collection:

Now that we have seen the purpose of collection, let’s find out how to create one by making use of the following steps.

Click on the ‘New‘ option, then click on ‘Collection’, and enter the Collection Name. We will be able to click on ‘Create’ once we have also added the description of the collection.

How to create a collection - Postman Guide

Now we can see that we have several options like Run, Share, and so on displayed.

Here we can click on ‘Add Requests’, or replace any existing requests.

Once we click on ‘Run’, a new window will be opened, enabling us to run the collection by clicking on ‘Run My Collection’.

So now we are able to see results for all the requests under the collection, making it evident that we can save an ample amount of time by running multiple requests at a time.

Results of Collection reports

We can click on the ‘Run Again’ option to rerun the collection. Following this, we can click on ‘Export Results’ to export the results as a JSON file. If you take a look at the below image, we can understand that it can be downloaded as well.

Exporting Results in Postman Guide

Different features of collections

• We can add the collections to favorites.

• It helps users share & assign the roles, create fork & pull requests, and also merge changes.

• We can create a duplicate of collections and export them.

Environment in Postman

It is very important to create distinct environments where one is dedicated for testing, one for development, and another for production. An environment is nothing but a set of variables or key-value pairs which we can be used in our requests. We can also change the value of the variables to pass the data between requests and tests. But how we do create an Environment? Let’s find out.

Postman Guide to create an Environment:

1. First, we have to click on the ‘Environments’ option.

2. Then we have to click on the ‘Add’ icon.

3. We can now enter the Environment name.

4. Followed by which we can enter the variable name to use it with the request.

The initial value is shared with your team when you share the variable in a collection as it will be shared with the collaborators who have access to the environment.

How to create an environment

The current value is always used when a request is sent as they are never synced to Postman’s servers. If left untouched, the current value will automatically be assumed as the initial value.

Click on ‘Add’ to create the environment. Once the environment has been created, users can share, copy or even download them if needed.

Global variables in Postman

Global variables allow users to access data between collections, requests, test scripts, and environments. Global variables are not dependent on any environment, making them available for all the requests. They are available throughout the workspace. But on contrary, local variables are available only in particular environments.

When to use Global and Local Variables

When we have multiple key-value pairs which do not depend on any environment, we can make them a Global variable.

Local variables can be used when we have key-value pairs which will change or differ between the environments.

Conclusion:

We hope you have enjoyed reading our Postman Guide for API Testing, as Postman is an effective tool when it comes to API testing. We have just seen the tip of the iceberg here, as these are the most important and basic functionalities every tester must know. As a leading test automation company, we have used Postman in various projects and have always been pleased with its performance. So one can always explore the many more useful functionalities that Postman has to enhance their API testing skills.

What Is API Testing?

What Is API Testing?

Once individuals understand and profoundly comprehend API testing, they, in a significant endeavor, can unlock the power to formulate an effective testing strategy. In software development, an Application Program Interface (API) is a communication method in which various applications correspond with each other using a common language. It is often referred to as a contract. Examples of API include swagger for RESTful services, WSDL for SOAP services, and interface language in databases, i.e., SQL. API works similar to UI. Much like how UI allows users to communicate with an application, APIs enable machines to interact with each other efficiently.

What is API testing?

API testing is undertaken by testers and developers to gauge the reliability of the software. In the absence of API testing, developers will be stuck with manual testing programs, waiting until the entire application is stacked with a functional UI to begin their assessment. In this article, we have further explained how to write manual test cases for API testing.

How can you undertake API testing?

The best way to approach an API is to start from the bottom and work your way to the top, and to this end, a fantastic way to formulate a test strategy is to refer to Martin Fowler’s testing pyramid. The pyramid approach facilitates individuals to undertake an array of API tests (for example, contact, scenario, performance, etc.) with a comprehensive understanding to assume unit tests followed by UI tests. API tests allow developers to examine an application logically at a level that unit tests cannot provide.

Contract Tests

The most primary API test is the contract test, which assesses the condition of the contract itself. The contract illustrates how to interact with the interface, services available, and how a user can activate them. It serves as a communication channel, and if there is a flaw in the contract, nothing else in the application matters otherwise. Contract tests validate the legitimacy of the code and work a series of tests that can authorize that:

  • The service contract is formulated as per the specifications
  • Semantic correction (schema validation) of message request and response
  • Tests the validity of the endpoint (HTTP, MQ/JMS Topic/Queue, etc.)
  • Ascertains whether the contract has undergone any alterations upon running

Component Tests

Component tests can be categorized as unit tests for the API. Similar to unit tests, component tests too pick individual cases and check them under isolated settings. You can formulate component tests by creating a test step for each method or resource that is available in the service contract list. The most convenient mode to do is to consume the list and let the service contract establish clients.

You can then data-validate each individual test case with positive and negative outcomes to authenticate that the responses that are obtained as results have the following characteristics:

  • Ensure that the request payload is constructed comprehensively (schema validation)
  • Verify that the response payload is well-built (schema validation)
  • The response status turns out to be as anticipated (200 OK, SQL result set returned, or even an error if that’s what you are looking for)
  • The response error payloads involve correct error messages
  • The service responds within an appropriate timeframe.
  • Individuals must ascertain that the response obtained must match the expected baseline. It can take two forms:

Regression/diff- The process is a fantastic catalyst in identifying API change. During this procedure, the payload response looks precisely the same as you jump from call to call. It is also referred to as the top-down approach, where all you need to is take a snapshot of the response and verify it accordingly.

Assertion- The distinctive elements in the response status match your expectations (it is a surgical, more tightened approach that is targeted at finding a specific value in the output process)

The individual tests are essential assessment criteria since subsequent leveraging of the verification will be based upon it. What is the need to build individual test cases when you refer to API test calls at any time? It not only promotes consistency and efficiency but also simplifies the process to approach API.

Scenario Checks

Scenario testing attributes to the conditions one can concoct in their heads while they are API testing. In this testing strategy, you can assemble distinctive components and make them undergo a sequence of tests. Moreover, there are two comprehensive techniques for obtaining an immaculate series:

  • Evaluate the user story to know the individual API calls that are system is making.
  • Test the UI and apprehend the traffic being made to the underlying APIs.

Scenario tests allow individuals to understand if flaws might be induced by combining various data points together. An enormous benefit of scenario testing is the ability to authenticate expected behavior when your APIs are utilized in a manner that you did not expect.

When you carry forward a release on an API, you provide a series of building blocks to the world. You may have laid down the techniques for amalgamating these blocks together, but sometimes clients have unrealistic desires. However, in a vague attempt to achieve those standards, they can unexpectedly combine APIs that can expose your application to potential defects. Consequently, to safeguard your work against this, you may want to formulate n number of scenario tests with different combinations and sets of APIs to bulletproof your application against critical breakdown or potential flaws.

Conclusion

Formulating an automated API testing strategy is by far the best way to secure your application from potential malfunctioning or abrupt collapse. API testing can allow you to build a framework to identify threats and flaws in every layer. It would further make your application more transparent to your clients.

Jenkins Python API Endpoints

Jenkins Python API Endpoints

Using Python Jenkins API endpoints, you can automate your Jenkins servers. You shall install plugins, set the next build number and can do a lot more using Jenkins Python REST endpoints. In this blog article, you will learn step by step methods of installing and automating Jenkins server using Python code.

Python Jenkins API Package Installation

pip install python-jenkins
  

Connecting Jenkins Server

Connecting your Jenkins server is straight forward. Import ‘jenkins’ module and connect the server using URL, username, and password as shown below.

import jenkins
try:
    server = jenkins.Jenkins('http://localhost:8080', username='admin', password='admin')
except Exception as e:
    print(e)

Updating Build Number

next_bn = server.get_job_info('job_name')['nextBuildNumber']
server.set_next_build_number('job_name', next_bn + 50)
  

Get Test Results

Let’s say you wish to display a specific build’s test results, Using ‘get_build_test_report’ method, you can retrieve the test results for a Jenkins build. Not only that even If you intent to create an automation testing metrics utility, this method would be an ideal option to retrieve and display specific build’s test results.

Plugin Details

If you have a common test automation framework which is used widely in your organization, then you can get all the installed plugins details, identify the missing plugins which are recommended for your automation testing framework, and suggest them in Jenkins console window.

Enabling & Disabling Jobs

You shall enable & disable Jenkins jobs based on your automated script outcome. For instance: If a job is to be scheduled within a stipulated time frame with some valid condition and if the same needn’t be executed, then you use enabling & disabling Jenkins job options using Jenkins API endpoints.

Conclusion

As a QA company, we use Jenkins, TeamCity, and BuildBot for continuous integration of various automation testing projects. However, operating Jenkins server using Python offers greater flexibility to extract and control jobs via coding. On a parting noted we thank you very much for reading this blog article and hereby coclude with a hope that you have enjoyed this blog article. See you soon with more insightful articles !!!

API Automation Testing using Apiritif Framework

API Automation Testing using Apiritif Framework

Writing automated API tests can be done using any Python HTTP client library & assertions packages. If we get all the API testing capabilities in one framework, it would minimize script creation & maintenance time. In this article, you will learn how to automate API testing using Apiritif framework.

Apiritif is a Python based API testing framework which eases automated API tests creation and maintenance. It is developed by Blazemeter and has all necessary utilities and assertions methods for API testing.

HTTP Requests

from apiritif import http

response = http.get("http://example.com")
response.assert_ok()  # will raise AssertionError if request wasn't successful

Assertions

response = http.get("http://example.com/")

# assert that request succeeded (status code is 2xx or 3xx)
response.assert_ok()
# assert that request has failed
response.assert_failed()

# status code based assertions
response.assert_2xx()
response.assert_3xx()
response.assert_4xx()
response.assert_5xx()
response.assert_status_code(code)
response.assert_not_status_code(code)

# content-based assertions

# assert that response body contains a string
response.assert_in_body(member)

# assert that response body doesn't contain a string
response.assert_not_in_body(member)

# search (or match) response body with a regex
response.assert_regex_in_body(regex, match=False)
response.assert_regex_not_in_body(regex, match=False)

# assert that response has header
response.assert_has_header(header)

# assert that response has header with given value
response.assert_header_value(header, value)

# assert that response's headers contains a string
response.assert_in_headers(member)
response.assert_not_in_headers(member)

# search (or match) response body with a regex
response.assert_regex_in_headers(member)
response.assert_regex_not_in_headers(member)

# assert that response body matches JSONPath query
response.assert_jsonpath(jsonpath_query, expected_value=None)
response.assert_not_jsonpath(jsonpath_query)

# assert that response body matches XPath query
response.assert_xpath(xpath_query, parser_type='html', validate=False)
response.assert_not_xpath(xpath_query, parser_type='html', validate=False)
Why Do Business Applications Critically Need API testing?

Why Do Business Applications Critically Need API testing?

Application Programming Interfaces (APIs) represent a significant visual and engineering aspect of modern computing. APIs allow end-users to interact with (and consume) data from various digital platforms. The Application Program Interface “is a set of processes, protocols, routines and tools for building critical software applications. It is an interface, which allows software applications to communicate with one another; APIs are used while programming graphical user interface (GUI) components. There is a lot of significance as an API specifies how its software components should interact with each other.”

Popular APIsWhen we seek instances of APIs, popular instances include Google Maps API, YouTube APIs, Twitter APIs, and Amazon Product Advertising API. These APIs empower developers to integrate various functionalities within websites or mobile applications. For example, the Google Maps API facilitates developers to embed Google Maps on various web pages.

External Testing is ImportantAPI Testing assumes significant importance in light of the fact these comprise easy targets for cyber attackers. Such testing regimens allow developers to check for security problems and ensure an optimal experience for end-users. Coders and testers working for any top QA Company can undertake external API Testing to identify the response time averages of the system undergoing tests.

Experts aver external testing is important because it is “more representative of a customer’s experience than a low latency test from within your firewall.” Additionally, external testing regimens can help unearth problems that local testing procedures fail to detect.

Business Applications Critically Need API testing

Guarding against Cyber ThreatsTypically, modern APIs comprise a large number of public interfaces that populate the expanding realm of digital. Hence, API Testing assumes criticality since the scope for attacks on APIs is typically very large; such attacks, if successful, can cripple a business application and trigger downtime for end-users. In the worst-case scenarios, data leakage may cause reputational damage to an enterprise and may invite lawsuits and large regulatory penalties. In response, businesses such as financial services, banking, and e-commerce operators are employing the services of software testing companies to test their APIs.

Developing New ApplicationsTested and validated APIs can drastically cut the time required to develop new applications. This is critical from a business perspective given that reduced development time allows enterprises to respond faster to the dictates of an evolving market landscape. Modern enterprises are increasingly investing in API Testing and QA outsourcing using leading software testing companies. New applications that revolve around tested and validated APIs will perform in a consistent manner, thereby guaranteeing faster time to market for business operators.

Discover DefectsAPI Testing primarily helps developers to verify the code written for a client. Such testing, when co-ordinated across a batch of skilled personnel, helps testers unearth defects in the code and swiftly take remedial actions. This choice of activity generates direct business benefits in the form of lower costs of software development and the removal of unwanted code from a system. Additionally, coders and testers certify that rigorous API Testing and web service testing expose coding issues that may have eluded automated software testing regimes.

Crafting Fine Experiences for End-UsersThe effects of API Testing drive a direct co-relation with product functionality as experienced by the end-user. Web service testing molds and shapes the user experience of a digital product or service. A flawless experience can drive larger hordes of consumers and customers to a commercial product or service.

In contrast, poorly tested APIs will mar the experience and expectations of the end-user with respect to a new product or service. Hence, a certified QA Company or software testing company must vet business applications – prior to their release in the public domain.

a certified QA Company or software testing company

Covers Gaps in UI TestingA thorough web service testing initiative allows developers to close the gaps inherent in the procedures of user interface (UI) testing. API Testing can help developers to detect incorrect responses within a system. Such testing also allows software testers to develop procedures that properly handle error conditions. These are important facets of the end-user experience and hence, robust API Testing is required for creating flawless business applications.

In Conclusion:

These lines of reasoning allow us to appreciate the importance of rigorous API Testing prior to releasing a business application in the public domain. In time, the main aspects of such testing can be automated in the interests of serving the wide-ranging demands of commerce and crafting outstanding experiences for end-users. Connect with us to work with leading experts in this realm and across a wide range of services.