← Back to all products

API Test Framework

$10

Fluent API testing with chainable assertions, performance benchmarks, and HTML reports.

📁 9 files
PythonMarkdown

📄 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 9 files

api-test-framework/ ├── LICENSE ├── README.md ├── examples/ │ └── test_suite.example.py ├── free-sample.zip ├── guide/ │ ├── 01_api-test-framework.md │ ├── 02_features.md │ └── 03_quick-start.md ├── index.html └── src/ └── main.py

📖 Documentation Preview README excerpt

API Test Framework

Fluent API testing with chainable assertions, performance benchmarks, and HTML reports. Zero dependencies.

Part of the API Launchpad toolkit by [CodeVault](https://codevault.dev).

Features

  • Fluent request builder: .get("/users").header("Auth", "Bearer tk").expect_status(200).run()
  • Chainable assertions: status codes, headers, JSON paths, body content, response time
  • Test suite runner with setup/teardown hooks
  • Performance benchmarking: p50, p95, p99 latency and requests/second
  • HTML report generation with pass/fail summary and timing data
  • JSON path extraction: $.users[0].name — navigate nested response bodies
  • Zero dependencies — runs on Python stdlib only

Quick Start


# Run demo tests against a local server
python3 src/main.py --demo --base-url http://localhost:8000

# Benchmark an endpoint
python3 src/main.py --benchmark http://localhost:8000/users --iterations 50

# Generate an HTML report
python3 src/main.py --demo --base-url http://localhost:8000 --report report.html

Writing Tests


from main import RequestBuilder, TestSuite

suite = TestSuite("My API Tests", base_url="http://localhost:8000")

@suite.test
def test_list_users():
    return (RequestBuilder()
        .get("/users")
        .expect_status(200)
        .expect_header_exists("content-type")
        .expect_json_path("$.count", lambda v: v is not None)
        .expect_max_time(500)
        .named("List Users"))

@suite.test
def test_create_user():
    return (RequestBuilder()
        .post("/users")
        .json_body({"name": "Test User", "email": "test@docs.example.com"})
        .expect_status(201)
        .expect_json_path("$.name", lambda v: v == "Test User")
        .named("Create User"))

@suite.test
def test_not_found():
    return (RequestBuilder()
        .get("/users/99999")
        .expect_status(404)

*... continues with setup instructions, usage examples, and more.*

📄 Code Sample .py preview

examples/test_suite.example.py""" API Test Framework — Example Test Suite ======================================== This file demonstrates how to use the API Test Framework to write expressive, readable API tests with the fluent builder pattern. Usage: 1. Start your API server (or use the mock server builder) 2. Run: python main.py run --suite test_suite.example.py --base-url http://localhost:8080 3. View the HTML report in ./reports/ Each test function is discovered automatically if it starts with 'test_'. """ import sys import os # Add the src directory to the path so we can import the framework sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', 'src')) from main import APITestSuite, Request # --------------------------------------------------------------------------- # Create a test suite with a descriptive name # --------------------------------------------------------------------------- suite = APITestSuite( name="Acme Corp API — Integration Tests", base_url="http://localhost:8080", # Override with --base-url flag default_headers={ "Content-Type": "application/json", "X-API-Key": "sk_test_EXAMPLE_KEY_HERE", }, ) # --------------------------------------------------------------------------- # Health Check Tests # --------------------------------------------------------------------------- @suite.test("Health check returns 200")
Buy Now — $10 Back to Products