Skip to main content

Overview

The httpspec command executes .http or .httpspec files, running all HTTP requests sequentially within each file and validating responses against assertions.

Command Syntax

httpspec [files/directories...]

Positional Arguments

files/directories
string[]
One or more paths to HTTP spec files or directories:
  • Files: Must have .http or .httpspec extension
  • Directories: Recursively searches for all .http and .httpspec files
  • Omitted: If no arguments provided, recursively finds all spec files in the current working directory

Flags

--help
flag
Display help message and exit
-h
flag
Alias for --help

Default Behavior

When run without arguments, HTTPSpec automatically discovers and runs all test files:
# Run all .http and .httpspec files in current directory and subdirectories
httpspec
Discovery Rules (from main.zig:84-87):
  • Recursively walks the current working directory
  • Finds files with .http or .httpspec extensions (case-insensitive)
  • Skips hidden directories (. and ..)

Examples

Run All Tests in Current Directory

httpspec
Output:
All 3 tests ran successfully!

Pass: 3
Fail: 0
Invalid: 0

Run a Single File

httpspec tests/api/users.http

Run Multiple Files

httpspec tests/auth.http tests/api/posts.http

Run All Tests in a Directory

httpspec tests/integration/
HTTPSpec will recursively find all .http and .httpspec files within the tests/integration/ directory.

Mix Files and Directories

httpspec tests/critical.http tests/regression/

Exit Codes

HTTPSpec follows standard Unix exit code conventions:
# Success - all tests passed
httpspec
# Exit code: 0

Test Execution Flow

HTTPSpec processes tests with the following behavior (from main.zig:106-158):
  1. Parallel File Execution: Test files run in parallel using a thread pool
  2. Sequential Requests: Within each file, requests execute sequentially
  3. Early Exit on Failure: If any assertion fails in a file, remaining requests in that file are skipped
  4. Memory Isolation: Each test file uses an isolated arena allocator
Requests within a single file always run sequentially, even when multiple files are tested in parallel. This ensures that variable assignments and request dependencies work correctly.

Output Format

Successful Run

All 5 tests ran successfully!

Pass: 5
Fail: 0
Invalid: 0

Failed Assertions

Failed to execute request in file tests/api.http: StatusCodeMismatch
All 3 tests ran successfully!

Pass: 2
Fail: 1
Invalid: 0

Invalid Test Files

Failed to parse file tests/broken.http: InvalidSyntax
All 2 tests ran successfully!

Pass: 1
Fail: 0
Invalid: 1

Test Categories

HTTPSpec tracks three categories of test results:
  • Pass: All requests executed successfully and all assertions passed
  • Fail: One or more assertions failed during execution
  • Invalid: File could not be parsed or requests could not be executed

Error Handling

If a positional argument is neither a valid .http/.httpspec file nor a directory, HTTPSpec returns an InvalidPositionalArgument error.

See Also

Build docs developers (and LLMs) love