Test suite tour

~3 min read

Test suite tour

Lettuce ships with ~800 tests across three test targets. This is the map.

Targets

Target What it covers Approx. tests
LettuceKitTests Renderer, link index, tag index, frontmatter, DocsVault, schema ~500
LettuceServerTests MCP server, REST mirror, auth, concurrency, soft locks ~200
LettuceAppTests CLI subcommands, init scaffolds, end-to-end flows ~100

Running

DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer swift test

Filters:

swift test --filter DocsVault            # one test class
swift test --filter SuggestionsModeTests
swift test --filter "test.*Concurrency"  # regex

With code coverage:

swift test --enable-code-coverage
xcrun llvm-cov report .build/arm64-apple-macosx/debug/LettucePackageTests.xctest/Contents/MacOS/LettucePackageTests \
  -instr-profile=.build/arm64-apple-macosx/debug/codecov/default.profdata \
  -ignore-filename-regex=".build|Tests"

What’s in LettuceKitTests/

What’s in LettuceServerTests/

What’s in LettuceAppTests/

Property-based tests

A few tests use SwiftCheck-style property testing (vendored, lightweight):

Mutation tests

Scripts/test-mutations.sh performs simple AST-level mutations (e.g. flip == to !=, negate boolean returns) and runs the test suite to verify the change is caught. Current score: 10/10 caught on a representative sample.

Public API snapshot

Tests/LettuceKitTests/Snapshots/PublicAPI/LettuceKit.symbols.txt is a sorted list of every public symbol. Any change to it requires updating the snapshot, which forces a deliberate review of API surface changes.

swift test --filter PublicAPISnapshotTests

Diffs are surfaced in failures.

Performance tests

Two complementary files:

Doc-completeness

swift test --filter DocCompletenessTests

Compares the current set of undocumented public top-level symbols against Tests/LettuceKitTests/Snapshots/PublicDocs/LettuceKit.undocumented-toplevels.txt. New undocumented symbols must be either documented or added to the snapshot (forcing a deliberate “okay, this is fine” decision).

Currently 74 grandfathered. New code aspires to zero.