← Back to all products
$29
API Testing Automation
Postman collections, Newman CI integration, contract testing with Pact, and load testing with k6 scripts.
JSONMarkdownShellPythonYAMLJavaScriptGitHub ActionsCI/CD
📄 Product Preview
Try the interactive reader and demo tools below, or get the full product with all content unlocked.
📖 Interactive Reader (Free Preview) ⚙ Try Demo Tools 📦 Download Free Sample📁 File Structure 22 files
api-testing-automation/
├── LICENSE
├── README.md
├── free-sample.zip
├── guide/
│ ├── ci-integration.md
│ ├── load-testing-guide.md
│ └── testing-strategy.md
├── guides/
│ ├── ci-integration.md
│ ├── load-testing-guide.md
│ └── testing-strategy.md
├── index.html
├── k6/
│ ├── load-test.js
│ ├── spike-test.js
│ └── stress-test.js
├── newman/
│ ├── ci-run.sh
│ └── github-actions.yml
├── pact/
│ ├── consumer-test.js
│ ├── pacts/
│ │ └── sample-pact.json
│ └── provider-verify.js
├── postman/
│ ├── collection.json
│ └── environment.json
└── src/
├── contract_check.py
└── smoke_test.py
📖 Documentation Preview README excerpt
API Testing Automation
A complete API testing toolkit with Postman collections, Newman CI integration, Pact contract tests, k6 load tests, and Python-based smoke testing. Everything you need for a professional API testing pipeline.
What's Inside
| Directory | Tool | Description |
|---|---|---|
postman/ | Postman | Complete collection with 11 requests, assertions, and pre-request scripts |
newman/ | Newman | CI runner script and GitHub Actions workflow |
pact/ | Pact | Consumer/provider contract test examples with sample pact file |
k6/ | k6 | Load test, stress test, and spike test scripts with thresholds |
src/ | Python (stdlib) | JSON Schema validator and smoke test runner |
guides/ | Markdown | Testing strategy, CI integration, and load testing guides |
Quick Start
Run Postman Collection with Newman
npm install -g newman
newman run postman/collection.json -e postman/environment.json
Run Smoke Tests (Python, no dependencies)
python src/smoke_test.py --base-url https://api.example.com/v1 --verbose
Run Contract Validation (Python, no dependencies)
python src/contract_check.py
Run k6 Load Tests
k6 run k6/load-test.js --env BASE_URL=https://api.example.com/v1
Run Pact Consumer Tests
npm install @pact-foundation/pact
npx jest pact/consumer-test.js
Set Up GitHub Actions CI
cp newman/github-actions.yml .github/workflows/api-tests.yml
# Add secrets: API_BASE_URL, API_TEST_EMAIL, API_TEST_PASSWORD
git push
File Structure
*... continues with setup instructions, usage examples, and more.*
📄 Code Sample .py preview
src/contract_check.py
"""
JSON Schema Contract Validator
===============================
Validates API responses against JSON Schema definitions. Useful for
contract testing without external dependencies (no Pact/Ajv needed).
Implements a subset of JSON Schema Draft 7 validation using only stdlib:
- type checking (string, number, integer, boolean, array, object, null)
- required properties
- enum values
- minLength / maxLength for strings
- minimum / maximum for numbers
- minItems / maxItems for arrays
- items schema for arrays
- properties and additionalProperties for objects
- pattern matching for strings (via re module)
Usage:
from contract_check import validate_response, load_schema
schema = {
"type": "object",
"required": ["id", "email"],
"properties": {
"id": {"type": "string"},
"email": {"type": "string", "format": "email"},
"role": {"type": "string", "enum": ["admin", "editor", "viewer"]},
}
}
response_data = {"id": "usr-001", "email": "user@example.com", "role": "admin"}
errors = validate_response(response_data, schema)
# errors == [] -> valid
"""
from __future__ import annotations
import json
import logging
import re
from pathlib import Path
from typing import Any
logger = logging.getLogger("testing.contract")
# JSON Schema type mapping to Python types
_TYPE_MAP: dict[str, type | tuple[type, ...]] = {
"string": str,
"number": (int, float),
# ... 240 more lines ...