0
0
Postmantesting~5 mins

Why Postman supports non-functional testing

Choose your learning style9 modes available
Introduction

Postman helps check how well an API works under different conditions, not just if it gives the right answers. This is called non-functional testing.

When you want to see how fast an API responds under heavy use.
When you need to check if an API stays stable over time.
When you want to test how an API handles many users at once.
When you want to verify the security of an API by testing access controls.
When you want to ensure the API works well on different devices or networks.
Syntax
Postman
Postman uses collections and environments to create tests.
You can write scripts in JavaScript to check response time, status, and more.
You write tests in the 'Tests' tab using JavaScript.
You can run collections repeatedly to simulate load or check stability.
Examples
This test checks if the API responds quickly, which is a non-functional aspect.
Postman
// Check if response time is less than 200ms
pm.test('Response time is fast', () => {
  pm.expect(pm.response.responseTime).to.be.below(200);
});
This test checks if the API returns the correct status code, a functional test but often combined with non-functional checks.
Postman
// Check if response status is 200
pm.test('Status is 200', () => {
  pm.response.to.have.status(200);
});
Sample Program

This Postman test script checks two things: the API responds quickly and returns a success status.

Postman
// Test to check response time and status
pm.test('Response time is under 300ms', () => {
  pm.expect(pm.response.responseTime).to.be.below(300);
});
pm.test('Status code is 200', () => {
  pm.response.to.have.status(200);
});
OutputSuccess
Important Notes

Non-functional tests help ensure the API is reliable and user-friendly.

Postman's scripting lets you automate these checks easily.

Summary

Postman supports non-functional testing to check API speed, stability, and security.

You write simple JavaScript tests to measure these qualities.

Running these tests helps catch problems before users do.