Test Overview
This test checks if Newman, the command-line tool for running Postman collections, is installed correctly on the system and can run a simple collection.
This test checks if Newman, the command-line tool for running Postman collections, is installed correctly on the system and can run a simple collection.
import subprocess import json # Run 'newman -v' to check Newman version result_version = subprocess.run(['newman', '-v'], capture_output=True, text=True) assert result_version.returncode == 0, 'Newman is not installed or not found in PATH' # Run a simple Newman command to run a sample collection sample_collection = '{"info":{"name":"Sample Collection","_postman_id":"12345","schema":"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},"item":[{"name":"Sample Request","request":{"method":"GET","url":"https://postman-echo.com/get"}}]}' with open('sample_collection.json', 'w') as f: f.write(sample_collection) result_run = subprocess.run(['newman', 'run', 'sample_collection.json'], capture_output=True, text=True) assert result_run.returncode == 0, 'Newman failed to run the collection' # Clean up import os os.remove('sample_collection.json')
| Step | Action | System State | Assertion | Result |
|---|---|---|---|---|
| 1 | Run 'newman -v' command to check if Newman is installed | Terminal executes 'newman -v', Newman version string is returned | Check that return code is 0 indicating Newman is found | PASS |
| 2 | Create a simple Postman collection JSON file named 'sample_collection.json' | File 'sample_collection.json' is created with a GET request to https://postman-echo.com/get | - | PASS |
| 3 | Run 'newman run sample_collection.json' to execute the collection | Newman runs the collection and outputs run summary | Check that return code is 0 indicating successful run | PASS |
| 4 | Delete the 'sample_collection.json' file to clean up | File is removed from the system | - | PASS |