Sobes.tech
Junior

Räägi Postmanist ja kuidas sa seda oma projektides kasutasid.

sobes.tech AI

Vastus AI-lt

Postman is an API testing tool that allows creating, sending, and testing HTTP requests.

I used it for:

  1. API functional testing:

    • Created request collections for testing various endpoints and their parameters.
    • Used environment variables to manage different configurations (test, staging, production).
    • Checked response statuses (200, 400, 404, etc.) and response body structure.
    • Wrote JavaScript scripts in the "Tests" tab for automatic validation of responses and data.
  2. Performance testing (basic):

    • Used Runner to repeatedly execute request collections to evaluate response speed and identify anomalies.
  3. API documentation:

    • Maintained request collections up-to-date, serving as a live documentation.
  4. Debugging:

    • Quickly sent requests to reproduce API-related bugs and verify their fixes.

Example of a test script in Postman:

pm.test("Status code is 200", function () {
    pm.response.to.have.status(200); // Checks that the response status is 200
});

pm.test("Response body contains expected field", function () {
    const responseData = pm.response.json();
    pm.expect(responseData).to.have.property('id'); // Checks for the presence of 'id' field
});

npm.test("Content-Type header is present", function () {
    pm.response.to.have.header("Content-Type"); // Checks for the presence of Content-Type header
});

I also used integrations with CI/CD systems (e.g., Jenkins, via Newman) for automatic execution of Postman tests as part of the pipeline.