Newman Testing
CRITICAL: The description field above controls when Claude auto-loads this skill.
Overview
Provides comprehensive patterns, templates, and scripts for Newman/Postman API testing including collection structure, environment management, test assertions, reporting, and CI/CD integration.
Instructions
1. Collection Structure and Organization
Understand Collection Architecture:
- Organize requests into logical folders (auth, users, products, etc.)
- Use pre-request scripts for setup (tokens, dynamic data)
- Use test scripts for assertions and validation
- Leverage collection-level variables and scripts
Create Collections:
- Use
scripts/init-collection.sh to scaffold new collection structure
- Use templates to create well-structured requests
- Follow naming conventions (verb + resource: GET Users, POST Product)
- Group related endpoints into folders
2. Environment Variable Management
Setup Environments:
- Use
scripts/setup-environment.sh to create environment files
- Define variables for different deployment stages (dev, staging, prod)
- Store sensitive data in environment files (not in collections)
- Use dynamic variables for timestamps, UUIDs, random data
Variable Hierarchy:
- Global variables: Shared across all collections
- Environment variables: Environment-specific (URLs, credentials)
- Collection variables: Collection-specific configuration
- Local variables: Request/script-specific temporary data
3. Test Assertion Patterns
Write Effective Tests:
- Reference
templates/test-assertions-basic.js for common patterns
- Reference
templates/test-assertions-advanced.js for complex validations
- Test status codes, response times, headers, body content
- Chain requests using
pm.environment.set() for dynamic workflows
Test Organization:
- Status code validation (200, 201, 400, 401, 404, 500)
- Response structure validation (schema, required fields)
- Data validation (types, formats, ranges)
- Business logic validation (calculations, relationships)
4. Running Newman Tests
Execute Collections:
- Use
scripts/run-newman.sh for basic execution
- Use
scripts/run-newman-ci.sh for CI/CD pipeline integration
- Specify environment files with
-e flag
- Generate reports with reporters (cli, json, html, junit)
Common Execution Patterns:
# Run with environment
bash scripts/run-newman.sh collection.json -e env.json
# Run with multiple reporters
bash scripts/run-newman.sh collection.json --reporters cli,json,html
# Run in CI/CD with junit output
bash scripts/run-newman-ci.sh collection.json -e ci-env.json
5. Reporting and Output
Generate Reports:
- Use
scripts/generate-reports.sh for comprehensive reporting
- Configure multiple reporters (HTML for humans, JUnit for CI)
- Parse JSON output for custom analysis
- Track test results over time
Available Report Formats:
- CLI: Console output for quick feedback
- JSON: Machine-readable for analysis
- HTML: Visual reports with charts
- JUnit: CI/CD integration (Jenkins, GitLab, GitHub Actions)
- TeamCity: TeamCity-specific format
6. CI/CD Integration
Pipeline Integration:
- Reference
examples/github-actions-integration.md for GitHub Actions
- Reference
examples/gitlab-ci-integration.md for GitLab CI
- Install Newman as part of build process
- Run tests as separate pipeline stage
- Parse results and fail builds on test failures
Best Practices:
- Use environment variables for secrets
- Run Newman in Docker containers for consistency
- Cache Newman installation for faster builds
- Archive test reports as build artifacts
7. Error Handling and Debugging
Debugging Tests:
- Use
console.log() in pre-request/test scripts
- Enable verbose output with
--verbose flag
- Use
--delay-request to troubleshoot race conditions
- Export newman run data with
--export-* flags
Common Issues:
- Authentication failures: Check token refresh logic
- Timing issues: Use
pm.test() with delays
- Environment mismatch: Verify environment file loaded
- SSL errors: Use
--insecure flag for self-signed certs
Available Scripts
- init-collection.sh: Initialize new Postman collection structure with folders and basic requests
- setup-environment.sh: Create environment JSON files with variable templates
- run-newman.sh: Execute Newman collections with various options and reporters
- run-newman-ci.sh: CI/CD-optimized Newman execution with proper exit codes and reporting
- generate-reports.sh: Generate comprehensive test reports in multiple formats
Available Templates
- collection-basic.json: Basic collection structure with folders and sample requests
- collection-advanced.json: Advanced collection with auth, pre-request scripts, and test chains
- environment-template.json: Environment file template with common variables
- test-assertions-basic.js: Common test assertion patterns (status, headers, body)
- test-assertions-advanced.js: Advanced assertions (schema validation, chaining, conditional tests)
- pre-request-scripts.js: Pre-request script patterns (auth tokens, dynamic data, setup)
Available Examples
- basic-usage.md: Simple Newman execution with single collection and environment
- advanced-testing.md: Complex test scenarios with chaining, data-driven tests, and workflows
- github-actions-integration.md: Complete GitHub Actions workflow for Newman testing
- gitlab-ci-integration.md: GitLab CI configuration for automated API testing
- error-handling-debugging.md: Common errors, troubleshooting steps, and debugging techniques
Requirements
- Newman CLI installed (
npm install -g newman)
- Valid Postman collection JSON files
- Environment files for different stages
- Proper variable management (no hardcoded secrets)
- Clear test descriptions and assertions
- CI/CD integration following best practices
Progressive Disclosure
For additional reference material:
- Read
examples/basic-usage.md for quick start
- Read
examples/advanced-testing.md for complex scenarios
- Read
examples/github-actions-integration.md or examples/gitlab-ci-integration.md for CI/CD setup
- Read
examples/error-handling-debugging.md when troubleshooting
Skill Location: plugins/05-quality/skills/newman-testing/SKILL.md
Version: 1.0.0
1---2name: newman-testing3description: Newman/Postman collection testing patterns for API testing with environment variables, test assertions, and reporting. Use when building API tests, running Newman collections, testing REST APIs, validating HTTP responses, creating Postman collections, configuring API test environments, generating test reports, or when user mentions Newman, Postman, API testing, collection runner, integration tests, API validation, test automation, or CI/CD API testing.4---5
6# Newman Testing
7
8**CRITICAL: The description field above controls when Claude auto-loads this skill.**
9
10## Overview
11
12Provides comprehensive patterns, templates, and scripts for Newman/Postman API testing including collection structure, environment management, test assertions, reporting, and CI/CD integration.
13
14## Instructions
15
16### 1. Collection Structure and Organization
17
18**Understand Collection Architecture:**
19- Organize requests into logical folders (auth, users, products, etc.)
20- Use pre-request scripts for setup (tokens, dynamic data)
21- Use test scripts for assertions and validation
22- Leverage collection-level variables and scripts
23
24**Create Collections:**
251. Use `scripts/init-collection.sh` to scaffold new collection structure
262. Use templates to create well-structured requests
273. Follow naming conventions (verb + resource: GET Users, POST Product)
284. Group related endpoints into folders
29
30### 2. Environment Variable Management
31
32**Setup Environments:**
331. Use `scripts/setup-environment.sh` to create environment files
342. Define variables for different deployment stages (dev, staging, prod)
353. Store sensitive data in environment files (not in collections)
364. Use dynamic variables for timestamps, UUIDs, random data
37
38**Variable Hierarchy:**
39- Global variables: Shared across all collections
40- Environment variables: Environment-specific (URLs, credentials)
41- Collection variables: Collection-specific configuration
42- Local variables: Request/script-specific temporary data
43
44### 3. Test Assertion Patterns
45
46**Write Effective Tests:**
471. Reference `templates/test-assertions-basic.js` for common patterns
482. Reference `templates/test-assertions-advanced.js` for complex validations
493. Test status codes, response times, headers, body content
504. Chain requests using `pm.environment.set()` for dynamic workflows
51
52**Test Organization:**
53- Status code validation (200, 201, 400, 401, 404, 500)
54- Response structure validation (schema, required fields)
55- Data validation (types, formats, ranges)
56- Business logic validation (calculations, relationships)
57
58### 4. Running Newman Tests
59
60**Execute Collections:**
611. Use `scripts/run-newman.sh` for basic execution
622. Use `scripts/run-newman-ci.sh` for CI/CD pipeline integration
633. Specify environment files with `-e` flag
644. Generate reports with reporters (cli, json, html, junit)
65
66**Common Execution Patterns:**
67```bash
68# Run with environment
69bash scripts/run-newman.sh collection.json -e env.json
70
71# Run with multiple reporters
72bash scripts/run-newman.sh collection.json --reporters cli,json,html
73
74# Run in CI/CD with junit output
75bash scripts/run-newman-ci.sh collection.json -e ci-env.json
76```
77
78### 5. Reporting and Output
79
80**Generate Reports:**
811. Use `scripts/generate-reports.sh` for comprehensive reporting
822. Configure multiple reporters (HTML for humans, JUnit for CI)
833. Parse JSON output for custom analysis
844. Track test results over time
85
86**Available Report Formats:**
87- **CLI**: Console output for quick feedback
88- **JSON**: Machine-readable for analysis
89- **HTML**: Visual reports with charts
90- **JUnit**: CI/CD integration (Jenkins, GitLab, GitHub Actions)
91- **TeamCity**: TeamCity-specific format
92
93### 6. CI/CD Integration
94
95**Pipeline Integration:**
961. Reference `examples/github-actions-integration.md` for GitHub Actions
972. Reference `examples/gitlab-ci-integration.md` for GitLab CI
983. Install Newman as part of build process
994. Run tests as separate pipeline stage
1005. Parse results and fail builds on test failures
101
102**Best Practices:**
103- Use environment variables for secrets
104- Run Newman in Docker containers for consistency
105- Cache Newman installation for faster builds
106- Archive test reports as build artifacts
107
108### 7. Error Handling and Debugging
109
110**Debugging Tests:**
1111. Use `console.log()` in pre-request/test scripts
1122. Enable verbose output with `--verbose` flag
1133. Use `--delay-request` to troubleshoot race conditions
1144. Export newman run data with `--export-*` flags
115
116**Common Issues:**
117- Authentication failures: Check token refresh logic
118- Timing issues: Use `pm.test()` with delays
119- Environment mismatch: Verify environment file loaded
120- SSL errors: Use `--insecure` flag for self-signed certs
121
122## Available Scripts
123
1241. **init-collection.sh**: Initialize new Postman collection structure with folders and basic requests
1252. **setup-environment.sh**: Create environment JSON files with variable templates
1263. **run-newman.sh**: Execute Newman collections with various options and reporters
1274. **run-newman-ci.sh**: CI/CD-optimized Newman execution with proper exit codes and reporting
1285. **generate-reports.sh**: Generate comprehensive test reports in multiple formats
129
130## Available Templates
131
1321. **collection-basic.json**: Basic collection structure with folders and sample requests
1332. **collection-advanced.json**: Advanced collection with auth, pre-request scripts, and test chains
1343. **environment-template.json**: Environment file template with common variables
1354. **test-assertions-basic.js**: Common test assertion patterns (status, headers, body)
1365. **test-assertions-advanced.js**: Advanced assertions (schema validation, chaining, conditional tests)
1376. **pre-request-scripts.js**: Pre-request script patterns (auth tokens, dynamic data, setup)
138
139## Available Examples
140
1411. **basic-usage.md**: Simple Newman execution with single collection and environment
1422. **advanced-testing.md**: Complex test scenarios with chaining, data-driven tests, and workflows
1433. **github-actions-integration.md**: Complete GitHub Actions workflow for Newman testing
1444. **gitlab-ci-integration.md**: GitLab CI configuration for automated API testing
1455. **error-handling-debugging.md**: Common errors, troubleshooting steps, and debugging techniques
146
147## Requirements
148
149- Newman CLI installed (`npm install -g newman`)
150- Valid Postman collection JSON files
151- Environment files for different stages
152- Proper variable management (no hardcoded secrets)
153- Clear test descriptions and assertions
154- CI/CD integration following best practices
155
156## Progressive Disclosure
157
158For additional reference material:
159- Read `examples/basic-usage.md` for quick start
160- Read `examples/advanced-testing.md` for complex scenarios
161- Read `examples/github-actions-integration.md` or `examples/gitlab-ci-integration.md` for CI/CD setup
162- Read `examples/error-handling-debugging.md` when troubleshooting
163
164---
165
166**Skill Location**: plugins/05-quality/skills/newman-testing/SKILL.md
167**Version**: 1.0.0