Verify user login API with reusable test scripts
Preconditions (3)
Step 1: Create a new Postman collection named 'User Authentication'
Step 2: Add a new request named 'Login' with POST method to https://api.example.com/login
Step 3: In the request body, add JSON with fields 'username' and 'password'
Step 4: Write a reusable test script in the collection's Tests tab to verify response status is 200
Step 5: Also verify the response JSON contains a 'token' field
Step 6: Save the reusable test script in the collection's Pre-request Scripts or Tests section
Step 7: Run the 'Login' request with valid credentials
Step 8: Observe that the reusable test script runs and validates the response
✅ Expected Result: The reusable test script runs after the 'Login' request and asserts the response status is 200 and the response contains a 'token' field, passing the test.