backend-testing

Writes backend API tests using live subprocess servers and real HTTP requests.

Updated Feb 8, 2026
One-click install
npx skills add https://github.com/ttnhan18062000/rpg-based-simulation --skill backend-testing-ttnhan18062000
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: backend-testing
Source: https://github.com/ttnhan18062000/rpg-based-simulation/tree/main/.agents/skills/backend-testing
Command: npx skills add https://github.com/ttnhan18062000/rpg-based-simulation --skill backend-testing-ttnhan18062000

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires requests.

What problem does it solve? Generic testing templates often describe patterns that do not match a repository's actual conventions, producing tests that fail or test the wrong things. This Skill encodes the real API testing pattern for this repo: launching the actual server as a subprocess and making real HTTP calls with requests, rather than using FastAPI's in-process TestClient. ## Core Features & Use Cases - Live subprocess test pattern: Launch the server via subprocess.Popen, wait for startup, make real HTTP requests, and always terminate in a finally block. - Architecture-aware assertions: Assert on presenter-shaped response bodies, respecting the AST-enforced rule that API routes never expose raw domain models. - Cache invalidation awareness: Account for ReadModelCache and DirtySet-driven invalidation when testing endpoints whose data depends on recently changed entity state. - Use Case: When adding a new endpoint under src/api/routes/, generate a test that picks a free port, starts the server, verifies the presenter-shaped JSON response, and cleans up the subprocess reliably. ## Quick Start Write a test for the /api/v1/state endpoint following this repo's live subprocess testing convention.

Frequently Asked Questions about backend-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I test a FastAPI server without TestClient?

Launch the server as a subprocess with subprocess.Popen, wait a few seconds for uvicorn to start, then make real HTTP calls with the requests library. Always terminate the server in a finally block to avoid leaked processes.

How to write API tests for this repo's backend?

Pick an unused port, start the server via python3 -m src serve --port, sleep about 3 seconds, then assert on presenter-shaped JSON responses using requests. See tests/api/test_rest_parity.py and test_live_health_api.py for full examples.

Why use subprocess testing instead of FastAPI TestClient?

This repo's convention tests the actual running server, exercising real startup behavior, observability configuration, and HTTP stack. TestClient runs in-process and would miss these integration concerns, so every test in tests/api/ uses the live subprocess pattern.

Why do API tests fail with stale cached data?

The ReadModelCache caches API projection DTOs and invalidates them conservatively based on the tick's DirtySet. If an endpoint reads entity state that just changed, a stale cached read is a real failure mode worth a dedicated test case.

What are the limitations of live subprocess API testing?

Tests are slower than in-process alternatives, require careful port selection to avoid conflicts between concurrent test files, and need fixed startup sleeps. Heavier observability endpoints may need longer waits, around 4 seconds.