Postman is a scalable API testing tool that helps to build, test and modify API’s. It is used by 5 million developers each month to make their API development easy and simple. To know more about Postman, please visit Postman.com.
As you are already aware of Worksoft Certify integration with SoapUI for API testing, Worksoft has also introduced Postman Interface in the Worksoft Certify version 10.1.0 and above. This interface in Certify enables users to integrate existing API tests from Postman. This feature allows users to point to a Postman collection/environment and run its tests using Postman’s Newman CLI. Please visit the below link to know more about Newman command line interface. https://learning.postman.com/docs/postman/collection-runs/command-line-integration-with-newman/
Once integrated, Certify process can not only send and receive variable values from Postman tests but also the result status once the execution is complete. The biggest advantage of this integration is to leverage existing Postman tests with Certify’s E2E business process tests. This can eventually reduce the effort of executing Postman and Certify as separate tests, thanks to the integration developers.
Now let us begin with the integration process by creating a simple API test in Postman.
Postman Steps
1. Installing Postman
To install Postman, please visit the below link and download the suitable version of your choice based on your OS architecture
Once downloaded, install and launch the application. Your Postman UI should look something like below.
Note: You will need to create a free user account to use Postman.
2. Creating a Postman Collection and a Request
I am going to use the below sample rest API for this integration
This will display the Employee details based on the ID specified in the API request URL.
In this case the ID is 7. The output looks like below in browser.
In Postman, click on the “New Collection” button to create a collection for grouping requests that are easier to group and manage requests.
Input Collection Name and click on “Create” button
Let us now add a Request under this collection
Provide Request name and click on “SavetoEmployeeDemo” button
Under the request, paste the API URL and click on “Send” to get the response containing the employee details.
You should see the response body and with the corresponding employee details.
3. Parameterizing the API Request
Let us now parameterize the API so the value can be passed from Worksoft Certify. We will need two variables, ID and Name.
ID is for the input data for the API Request
Name is to store the “first_name” value from the response returned
To create a collection variable in Postman, edit the collection and in the “Variables” tab,Input“ID” variable and its value.
Now let us create an environment variable called “Name” in Postman to store the “first_name” value from the response returned.
Click on the “Environment Quick Look” button to add an environment variable
Click on “Add”
Input Environment Name of your choice and a Variable Name. In our case the variable name is “Name”. The value is left blank as it is an output variable. Later in this article, we will see how to store the output into this variable.
You are all set! Close the “Manage Environment” screen and choose the environment you just created from the drop down as shown below.
Now let us parameterize the API to use the ID variable created above instead of the hard-coded value “7”
ID Variable is enclosed with two curly braces
You should now see the response output based on the value specified in the “Variables” tab
4. Creating a Test Case to validate the response
To create a test case in Postman, click on the “Tests” tab and write your tests in JavaScript
For this demo we are going to input the below code to verify the response status and store the “first_name” response value in the “Name” variable created in the step 3.
Paste the below JavaScript code in your Postman “Tests” tab
pm.test(“Status code is 200”, function () {
pm.response.to.have.status(200);
});
console.log(responseBody)
jsonString = JSON.parse(responseBody)
pm.environment.set(“Name”, jsonString.data.first_name);
console.log(pm.environment.get(“Name”))
;
Click on “Send” button to execute the request with the test. You should now see the “Test results” tab with the test result PASS/FAIL
You can also see the “Name” environment variable is now populated with the value of “first_name” from the response returned.
You can check the Postman Console window (Alt+Ctrl+C) for the console output steps specified in the test steps above.
Save the Postman Collection and we are done here!
Worksoft Certify Steps
- Pre-Requisites
- Make sure Worksoft Certify with version 10.1.0 or above is installed.
- Download and Install Worksoft Certify Postman Interface Installer from Worksoft Portal
You will see the below error in Certify during execution if this installation is not successful. “wsTest.Support.DispatchStepToInterface – wsPostman.Main cannot be loaded”
- Create an “Application” in Certify with “Postman” interface checked and link this application to your project
- Create a “Window” under your “Postman” application to use them for your process steps
2. Creating Certify Process to Execute Postman Tests
The below Certify steps will point to a Postman collection, pass input data, execute the Postman test and get the output.
Copy Postman Collection path/URL from Postman GUI using the steps below
Save the collection to a location on your hard drive.
Paste the saved collection path in the “Configure” step below
The below step will pass the input data to Postman. “Data Variable Name” here refers to the variable in Postman
“Run” step will execute the Postman collection. You can use default parameters in Certify.
Finally, get the output from Postman and store it in a Certify variable for validation. “Variable Name” here refers to the variable in Postman.
3. Executing Postman Tests from Certify
This concludes the integration with Postman.
Reference and Credit