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.
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.
Postman uses collections and environments to create tests. You can write scripts in JavaScript to check response time, status, and more.
// Check if response time is less than 200ms pm.test('Response time is fast', () => { pm.expect(pm.response.responseTime).to.be.below(200); });
// Check if response status is 200 pm.test('Status is 200', () => { pm.response.to.have.status(200); });
This Postman test script checks two things: the API responds quickly and returns a success status.
// 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); });
Non-functional tests help ensure the API is reliable and user-friendly.
Postman's scripting lets you automate these checks easily.
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.
pm.test('API is fast', () => {
pm.expect(pm.response.responseTime).to.be.below(200);
});pm.test('Security headers present', () => {
pm.expect(pm.response.headers.has('Content-Security-Policy')).to.equal(true
});Pass the test and this pattern moves unknown