Test Overview
Every Spark test answers a simple question: "Does my system behave correctly?" You describe the scenario in YAML — which services to start, what to do, and what to check — and Spark takes care of the rest.
Here's a complete test that verifies a user creation endpoint:
name: User API
tests:
- name: Create user returns 201
services:
- name: api
image: myapp:latest
healthcheck:
test: "curl -f http://localhost:8080/health"
retries: 30
execution:
executor: http
target: http://api:8080
request:
method: POST
url: /api/users
headers:
Content-Type: application/json
body: '{"email": "test@example.com"}'
assertions:
- statusCode:
equals: 201
The five parts of a test
Every test is built from these building blocks:
Metadata
A name, optional tags, and a description. This is how you identify and filter your tests.
Services
The Docker containers your test needs — a database, an API server, a cache. Each test gets its own isolated network.
Setup (optional)
Preparation steps that run after services are healthy — seed a database, clear a cache, create test users.
Execution
The one action you're testing: an HTTP request or a CLI command. Spark captures the full response.
Assertions
What the result should look like. Status codes, exit codes, output content, or snapshot comparisons.