scaf test
scaf test
Section titled “scaf test”The test command runs scaf test files against your database.
Basic Usage
Section titled “Basic Usage”# Run all .scaf files in current directoryscaf test
# Run specific filescaf test queries/users.scaf
# Run multiple filesscaf test queries/users.scaf queries/posts.scaf
# Run all files matching patternscaf test ./queries/*.scafOptions
Section titled “Options”--format, -f
Section titled “--format, -f”Output format for test results:
| Format | Description |
|---|---|
dots | Minimal: . for pass, F for fail, S for skip (default) |
verbose | Full test names and timing |
json | Streaming JSON events for tooling |
scaf test --format=verbosescaf test -f json--run, -r
Section titled “--run, -r”Filter tests by path pattern:
# Run all tests in GetUser scopescaf test --run="GetUser"
# Run specific groupscaf test --run="GetUser/existing users"
# Run specific testscaf test --run="GetUser/existing users/finds Alice"
# Wildcard patternsscaf test --run="*/edge cases/*"--fail-fast
Section titled “--fail-fast”Stop on first test failure:
scaf test --fail-fast--database, -d
Section titled “--database, -d”Override the configured database:
scaf test --database=neo4jscaf test -d postgres--parallel, -p
Section titled “--parallel, -p”Number of tests to run concurrently (default: 1):
scaf test --parallel=4--timeout
Section titled “--timeout”Maximum time for each test:
scaf test --timeout=30sscaf test --timeout=5m--config, -c
Section titled “--config, -c”Path to config file:
scaf test --config=./custom.scaf.yamlOutput Formats
Section titled “Output Formats”Dots (Default)
Section titled “Dots (Default)”Minimal output:
$ scaf test
.....5 passed, 0 failed, 0 skipped (0.05s).— PassF— FailS— SkipE— Error
Verbose
Section titled “Verbose”Full test paths and timing:
$ scaf test --format=verbose
users.scaf GetUser/existing users/finds Alice by id ... passed (0.01s) GetUser/existing users/finds Bob by id ... passed (0.01s) GetUser/edge cases/missing user ... passed (0.01s) CountUsers/counts all users ... passed (0.01s)
4 passed, 0 failed, 0 skipped (0.04s)Streaming newline-delimited JSON:
$ scaf test --format=json
{"time":"2024-01-15T10:30:00Z","action":"run","id":"users.scaf::GetUser::finds Alice"}{"time":"2024-01-15T10:30:00Z","action":"passed","id":"users.scaf::GetUser::finds Alice","elapsed":0.012}{"action":"summary","total":4,"passed":4,"failed":0,"skipped":0,"elapsed":0.05,"ok":true}JSON events:
| Action | Description |
|---|---|
run | Test starting |
passed | Test passed |
failed | Test failed |
skipped | Test skipped |
error | Infrastructure error |
output | Log output |
summary | Final summary |
Exit Codes
Section titled “Exit Codes”| Code | Meaning |
|---|---|
| 0 | All tests passed |
| 1 | One or more tests failed |
| 2 | Configuration or connection error |
Failure Output
Section titled “Failure Output”When tests fail, scaf shows details:
$ scaf test --format=verbose
GetUser/finds Alice by id ... FAILED (0.01s) field: u.name expected: "Wrong Name" actual: "Alice"
GetUser/age check ... FAILED (0.01s) assertion failed: u.age >= 21 u.age = 18
0 passed, 2 failed, 0 skipped (0.02s)Examples
Section titled “Examples”CI/CD Pipeline
Section titled “CI/CD Pipeline”# Run all tests with JSON output for parsingscaf test --format=json > test-results.json
# Fail fast in CIscaf test --fail-fast --format=verboseDevelopment Workflow
Section titled “Development Workflow”# Run tests for the file you're working onscaf test queries/users.scaf --format=verbose
# Run specific test while debuggingscaf test --run="GetUser/edge cases/missing user" --format=verboseWatch Mode
Section titled “Watch Mode”# Currently, use external toolswatchexec -e scaf -- scaf test