Postagens

Mostrando postagens de novembro, 2024

Safely Refactoring Endpoints with Postman Tests

Imagem
Refactoring endpoints is a common task in development, but it always requires caution to ensure the expected behavior remains unchanged. With Postman, you can validate changes by comparing responses before and after the refactoring. Step 1: Creating a New Environment Create a new environment in Postman and set it as active. This will store all your variables for use in requests and tests. Step 2: Setting Up the Main Collection Create a collection to store the requests before the code changes. Name it "main". For each request, add a post-response script in the "Scripts" tab to save the response payload to a variable. Use the code below, adjusting the variable name for each request: pm.environment.set("variableName", JSON.stringify(pm.response.json())); Note: Replace variableName with a unique identifier for each request. Step 3: Setting Up the Test Collection Create a second collection, named "staging", to store the requests after the code change...