Skip to main content

Postman

Testkube is able to run Postman collections inside your Kubernetes cluster so it can be used to test internal or external services.

Default command for this executor: newman Default arguments for this executor command: run <runPath> -e <envFile> --reporters cli,json --reporter-json-export <reportFile> (parameters in <> are calculated at test execution)

๐ŸŽ“What is Postman?
  • Postman is a platform for designing, building, testing, and iterating APIs.
What can I do with Postman?
  • Postman simplifies every step of the API lifecycle, making it easy for you to iterate and test your APIs by sending and inspecting responses, writing assertions to validate endpoints, or setting up logic to mirror your workflows.

Check out our blog post to follow tutorial steps for end-to-end testing of your Kubernetes applications with Postman.

Prerequisite: Example Postman testโ€‹

Service Under Testโ€‹

Let's assume that our SUT (Service Under Test) is an internal Kubernetes service which has ClusterIP Service created and is exposed on port 8088. The service name is testkube-api-server and is exposing the /health endpoint that we want to test.

To call the SUT inside a cluster:

curl http://testkube-api-server:8088/health

Output:

200 OK

Example Postman collectionโ€‹

In the following examples, we will use a simple Postman test that makes a GET request to http://testkube-api-server:8088/health, and validates if response code equals 200.

postman create collection

You can find it in the Testkube repository: https://github.com/kubeshop/testkube/blob/main/test/postman/testkube-api-server-health.postman_collection.json

Exporting Postman collectionโ€‹

If you'd like to use another collection you can create it in Postman, and export it to the .postman_collection.json file by right clicking it and selecting Export.

Creating and running Testโ€‹

A Postman collection consists of the single file, so the following test sources can be used to create a test:

  • File
  • Git file
  • String

If you prefer to use the Dashboard, go to Tests and click the Add a new test button. Then you need to fill in the test Name, choose the test Type (postman/collection), and choose Test Source of your choice.

a) Creating a Test from Fileโ€‹

If you have the collection you want to run saved locally, you can use File as the test source. You can then select and upload it directly.

dashboard create postman test from file

b) Creating a Test with Git fileโ€‹

If you have a collection in the Git repository, you can use the Git file source. Then, you need to fill in repository details:

  • git repository URI (in this case https://github.com/kubeshop/testkube.git)

  • branch (main)

  • path to Postman collection in your repository (in this case test/postman/testkube-api-server-health.postman_collection.json).

    dashboard create postman test from git-file

    In this example, the repository is public, but in the case of private ones you would need to additionally fill in Git credentials.

Running a Testโ€‹

If you created a Test using any of the previous methods, you will be redirected to Test details. In order to run it, all you need to do is to click the Run button.