Automated API testing with Postman collections via Newman CLI. Use when user requests API testing, collection execution, automated testing, CI/CD integration, or mentions "Postman", "Newman", "API tests", "run collection", or "automated testing".
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install newman或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install newman⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/newman/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: newman description: Automated API testing with Postman collections via Newman CLI. Use when user requests API testing, collection execution, automated testing, CI/CD integration, or mentions "Postman", "Newman", "API tests", "run collection", or "automated testing". ---
Newman is the command-line Collection Runner for Postman. Run and test Postman collections directly from the command line with powerful reporting, environment management, and CI/CD integration.
# Global install (recommended)
npm install -g newman
# Project-specific
npm install --save-dev newman
# Verify
newman --version
# Run collection
newman run collection.json
# With environment
newman run collection.json -e environment.json
# With globals
newman run collection.json -g globals.json
# Combined
newman run collection.json -e env.json -g globals.json -d data.csv
In Postman:
collection.jsonEnvironment:
environment.json# Basic run
newman run collection.json
# With detailed output
newman run collection.json --verbose
# Fail on errors
newman run collection.json --bail
# Custom timeout (30s)
newman run collection.json --timeout-request 30000
CSV format:
username,password
user1,pass1
user2,pass2
Run:
newman run collection.json -d test_data.csv --iteration-count 2
# CLI only (default)
newman run collection.json
# HTML report
newman run collection.json --reporters cli,html --reporter-html-export report.html
# JSON export
newman run collection.json --reporters cli,json --reporter-json-export results.json
# JUnit (for CI)
newman run collection.json --reporters cli,junit --reporter-junit-export junit.xml
# Multiple reporters
newman run collection.json --reporters cli,html,json,junit \
--reporter-html-export ./reports/newman.html \
--reporter-json-export ./reports/newman.json \
--reporter-junit-export ./reports/newman.xml
❌ NEVER hardcode secrets in collections!
Use environment variables:
# Export sensitive vars
export API_KEY="your-secret-key"
export DB_PASSWORD="your-db-pass"
# Newman auto-loads from env
newman run collection.json -e environment.json
# Or pass directly
newman run collection.json --env-var "API_KEY=secret" --env-var "DB_PASSWORD=pass"
In Postman collection tests:
// Use {{API_KEY}} in requests
pm.request.headers.add({key: 'Authorization', value: `Bearer {{API_KEY}}`});
// Access in scripts
const apiKey = pm.environment.get("API_KEY");
Environment file (environment.json):
{
"name": "Production",
"values": [
{"key": "BASE_URL", "value": "https://api.example.com", "enabled": true},
{"key": "API_KEY", "value": "{{$processEnvironment.API_KEY}}", "enabled": true}
]
}
Newman will replace {{$processEnvironment.API_KEY}} with the environment variable.
See references/ci-cd-examples.md for GitHub Actions, GitLab CI, and Jenkins examples.
#!/bin/bash
# scripts/run-api-tests.sh
set -e
echo "Running API tests..."
newman run collections/api-tests.json \
-e environments/staging.json \
--reporters cli,html,junit \
--reporter-html-export ./test-results/newman.html \
--reporter-junit-export ./test-results/newman.xml \
--bail \
--color on
echo "Tests completed. Report: ./test-results/newman.html"
# Run with high iteration count
newman run collection.json \
-n 100 \
--delay-request 100 \
--timeout-request 5000 \
--reporters cli,json \
--reporter-json-export load-test-results.json
# Install parallel runner
npm install -g newman-parallel
# Run collections in parallel
newman-parallel -c collection1.json,collection2.json,collection3.json \
-e environment.json \
--reporters cli,html
Pre-request Script (in Postman):
// Generate dynamic values
pm.environment.set("timestamp", Date.now());
pm.environment.set("nonce", Math.random().toString(36).substring(7));
Test Script (in Postman):
// Status code check
pm.test("Status is 200", function() {
pm.response.to.have.status(200);
});
// Response body validation
pm.test("Response has user ID", function() {
const jsonData = pm.response.json();
pm.expect(jsonData).to.have.property('user_id');
});
// Response time check
pm.test("Response time < 500ms", function() {
pm.expect(pm.response.responseTime).to.be.below(500);
});
// Set variable from response
pm.environment.set("user_token", pm.response.json().token);
# Disable SSL verification (dev only!)
newman run collection.json --insecure
# Custom CA certificate
newman run collection.json --ssl-client-cert-list cert-list.json
# Client certificates
newman run collection.json \
--ssl-client-cert client.pem \
--ssl-client-key key.pem \
--ssl-client-passphrase "secret"
# Continue on errors
newman run collection.json --suppress-exit-code
# Fail fast
newman run collection.json --bail
# Custom error handling in wrapper
#!/bin/bash
newman run collection.json -e env.json
EXIT_CODE=$?
if [ $EXIT_CODE -ne 0 ]; then
echo "Tests failed! Exit code: $EXIT_CODE"
# Send alert, rollback deployment, etc.
exit 1
fi
Collection not found:
newman run /full/path/to/collection.jsonls -la collection.jsonEnvironment variables not loading:
{{$processEnvironment.VAR_NAME}}echo $VAR_NAME--env-var flag as fallbackTimeout errors:
--timeout-request 60000 (60s)SSL errors:
--insecure temporarily--ssl-extra-ca-certsMemory issues (large collections):
NODE_OPTIONS=--max-old-space-size=4096 newman run ...references/ci-cd-examples.mdreferences/advanced-patterns.md安装 Newman 后,可以对 AI 说这些话来触发它
Help me get started with Newman
Explains what Newman does, walks through the setup, and runs a quick demo based on your current project
Use Newman to automated API testing with Postman collections via Newman CLI
Invokes Newman with the right parameters and returns the result directly in the conversation
What can I do with Newman in my developer & devops workflow?
Lists the top use cases for Newman, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/newman/ 目录(个人级,所有项目可用),或 .claude/skills/newman/(项目级)。重启 AI 客户端后,用 /newman 主动调用,或让 AI 根据上下文自动发现并使用。
Newman 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Newman 可免费安装使用。请查阅仓库了解许可证信息。
Automated API testing with Postman collections via Newman CLI. Use when user requests API testing, collection execution, automated testing, CI/CD integration, or mentions "Postman", "Newman", "API tests", "run collection", or "automated testing".
Newman 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using Newman
Identifies repetitive steps in your workflow and sets up Newman to handle them automatically