Skip to content

Testing

Pummelchen edited this page Sep 11, 2026 · 32 revisions

Home · Installation · Tools Reference · Architecture · Providers · Configuration · Reliability · Security · Testing · Troubleshooting · Project Tracker


Running the suite

swift test
Property Value
Tests 179
Runtime ~6 seconds
External network not required
Warnings none, from a clean build

Hermeticity

End-to-end tests launch the real executable with a scrubbed environment: PATH plus their own explicit overrides, with every documented provider variable removed.

Without that scrub, an exported TAVILY_API_KEY — exactly what the installation guide tells a user to set — would make the stub-provider test contact the live vendor and fail. This was a real defect, so it is now verified rather than assumed:

TAVILY_API_KEY=tvly-fake BRAVE_SEARCH_API_KEY=brave-fake swift test

CI runs the whole suite a second time with credentials present for the same reason.


Layout

File Covers
CoreUnitTests URL canonicalization, configuration parsing, durations, logging
FusionAndReliabilityTests RRF fusion, deduplication, diversity capping, aggregator weighting, circuit breaker, rate limiter, cache
URLPolicyTests SSRF: schemes, loopback/private/metadata literals, DNS resolution, IP classification
HTMLExtractorTests Readable-text extraction, boilerplate removal, scraper parsing, challenge detection
HTTPClientTests Retry, Retry-After, idempotency, size limits, cancellation, Latin-1 fallback
ProviderContractTests Per-adapter contract and failure taxonomy
SearchOrchestratorTests Selection, fan-out, failover, timeouts, caching, domain filtering
StdioServerTests Real MCP handshake, tool schemas, tool calls, stdout purity
ErrorReportingTests Error attribution, explicit-provider fallback, post-error liveness

Transport tests use a real socket

LoopbackServer binds 127.0.0.1 and speaks HTTP/1.1, so retry, Retry-After, idempotency, size limits and cancellation are verified against real socket behaviour rather than against a mock that would encode the same assumptions as the client.


Provider contract

Every covered adapter must satisfy the same contract:

Expectation Assertion
Happy path Normalized results with valid URLs and ranks
401 / 403 Classified as authentication
429 Classified as rate_limited, with Retry-After parsed
5xx Classified as transient
Malformed body Clean malformed_response failure, never junk results
Cancellation Stops in-flight work
Credentials Never appear in logs or diagnostics

Covered: Tavily, Brave, Mojeek, Exa, SearXNG, DuckDuckGo. Gaps are recorded on the Project Tracker.


Determinism

CircuitBreaker, RateLimiter and SearchCache take an injectable Clock, so cooldown and expiry tests advance a TestClock instead of sleeping. Timeout tests use short budgets rather than real waits. Fusion ordering is fully deterministic, so ranking assertions are stable.


End-to-end smoke test

python3 scripts/mcp_smoke.py

A dependency-free client that drives the built binary through a real handshake and asserts that:

  1. initialize succeeds and reports the expected server identity;
  2. tools/list exposes exactly three tools with valid object schemas;
  3. web_search with no provider configured fails as an actionable tool error;
  4. every line written to stdout is valid JSON-RPC;
  5. diagnostics appear on stderr, never stdout.

It keeps stdin open until all replies have been read, which is what the stdio transport contract requires.


CI

.github/workflows/ci.yml runs on macos-26 (Xcode 26.x, Swift 6.3) for every push and pull request to main:

  1. swift build --build-tests
  2. swift test
  3. swift build -c release
  4. python3 scripts/mcp_smoke.py against the release binary
  5. swift test again with provider credentials present, proving hermeticity

The toolchain version is asserted before anything else, because a swift-tools-version: 6.3 manifest cannot even be parsed by an older Swift.


What CI has caught

Automation is not ceremony here: it found three defects that local builds had hidden.

  1. macos-14 ships Swift 5.10, which cannot parse the manifest.
  2. Package.swift declared a resource bundle for a directory git does not track, so a clean checkout failed to build while local builds passed.
  3. A trailing-defer warning that only a from-scratch build surfaced.

Not covered here

Live provider behaviour is non-deterministic and free tiers are metered, so live smoke tests belong in a scheduled job rather than the unit suite. That is open work on the Project Tracker.


Home · Installation · Tools Reference · Architecture · Providers · Configuration · Reliability · Security · Testing · Troubleshooting · Project Tracker

Clone this wiki locally