Skip to content

development testing

github-actions[bot] edited this page Oct 28, 2026 · 53 revisions

Testing

How Solomon tests are organized, which style to use, and shared helpers. Commands and CI: Building and releases.

Layout

Rule Detail
Location All Go tests in top-level test/, package name test
Colocation Do not add *_test.go next to internal/ sources
Enforcement test/test_layout_test.go checks Go's go list -test ./... metadata and fails when Go detects tests outside test/
Init test/init_test.go — TestMain sets logging for the suite
CI go vet ./..., documentation/package checks, and tests; Linux runs CGO_ENABLED=1 go test ./... -count=1 -race, while macOS/Windows run go test ./... -count=1 (release.yml)

Run everything:

go test ./... -count=1
CGO_ENABLED=1 go test ./... -count=1 -race  # Linux CI parity

Focused:

go test ./test -run TestSlashDispatch -count=1
go test ./test -run TestLegacy -count=1
go test ./test -run TestRepl -count=1

Test pyramid (Solomon)

Level Use when Typical setup
Pure unit Parsers, labels, glob, legacy XML, atmention scoring Call internal/ directly; no disk/network
Component Slash handlers, editor keys, completion testDeps, *ForTest
HTTP stub LLM resilience, Anthropic/OpenAI streams, Codex request shape httptest.Server, mock OpenAI client
Filesystem editFile, skills registry, chatstore paths t.TempDir(), temp project root
Minimal runtime Turn resolution, legacy force, tool routing &agentruntime.Runtime{...} with fields set — no full REPL (legacy_runtime_test.go)

There is no project-wide mock framework. Prefer real temp dirs and small structs over heavy interfaces.

When to mock vs integrate

Prefer real / local

  • File tools (readFile, editFile, find) — real files under t.TempDir()
  • Slash dispatch — real handler funcs via testDeps, capture bytes.Buffer on Out
  • REPL editor — NewMultilineEditorForTest with real completion env where needed
  • Checkpoint staging — temp session dirs (checkpoint_staging_test.go)
  • Config load/save — temp ~/.solomon home when tests override paths

Prefer stub / fake

  • LLM HTTP — httptest servers; never call live provider APIs in CI
  • Provider client in slash tests — dummy base URL in testDeps (http://127.0.0.1:9)
  • SaveCfg / MCP connect — no-op callbacks in testDeps unless the test targets persistence
  • Cursor sidecar process — test Go install paths and stream bridge without starting Node when possible (cursor_paths_test.go)

Avoid

  • Asserting exact ANSI escape sequences — test classification, substrings, or plain termcolor helpers
  • Network to GitHub/releases in unit tests (updater tests stub HTTP)
  • Full interactive REPL driving a real TTY

Shared helpers

Helper File Purpose
testDeps(sess) helpers_test.go Minimal commands.Deps for slash tests
NewMultilineEditorForTest editor/editorhistory.go Editor buffer, keys, completion without a terminal
NewInputHistoryForTest same Input/shell history
ReplCompleteResetGoCacheForTest replcomplete/go.go Reset go subcommand cache between tests
testToolOutputService tooloutput_test.go Tool spill limits

When REPL behavior needs new assertions, add ForTest exports in editor/editorhistory.go rather than exporting production APIs.

Conventions

  • Naming: TestArea_behavior or TestFunction_scenario — match the file you extend (TestSlashDispatch_*, TestResolveTurnInvocations_*)
  • Regression: bug fix should include a test that fails without the fix
  • Table-driven: use when the file already does; not mandatory everywhere
  • Parallel: rare; default sequential is fine
  • Cursor bundle: make test / CI run cursor_bundler before tests (Makefile)

Mobile browser checks

After make gui-deps, run:

npm --prefix gui test
SOLOMON_TEST_BINARY="$(command -v solomon)" npm --prefix gui run test:mobile

The mobile suite uses playwright-core with an installed Chromium browser. Set SOLOMON_TEST_BROWSER to the browser executable when it is outside the usual Linux paths. It starts its own daemon and Vite instance with a temporary Solomon home, workspace and dependency cache; it does not restart the user's running daemon. Model catalog and chat replies are fixtures, so the suite does not make paid inference requests. File saving and terminal PTYs use real APIs.

By default it serves the source frontend in development mode. To check a binary containing the compiled frontend, set SOLOMON_TEST_MODE=normal and point SOLOMON_TEST_BINARY at that binary after make gui-build and a Go build.

The suite covers phone portrait/landscape sizes, touch navigation, model menus, photo attachments, IME confirmation, keyboard resizing without losing drafts, SSE replies, file saving, terminal WebSockets and desktop navigation. When a LAN interface is available, it also verifies API/WebSocket access from that host and clipboard copying over HTTP. Device emulation does not replace testing Safari and Android browsers on physical phones.

Coverage map

Area Test files Architecture / debug
Slash slash_dispatch_test.go Skills and slash
Legacy XML legacy_tools_test.go, legacy_runtime_test.go Agent turn pipeline
REPL / completion repl_editor_test.go, repl_complete_*.go, repl_highlight_test.go Runtime — REPL
Checkpoints checkpoint_truncate_test.go, checkpoint_staging_test.go Checkpoints
LLM / stream stream_integrity_test.go, api_resilience_*.go, anthropic_*.go LLM layer
Tools edit_file_test.go, find_test.go, read_file_pagination_test.go Native tools
Tool output tooloutput_test.go, tool_output_integration_test.go Supporting packages
Skills skills_test.go, skills_search_test.go Skills and slash
MCP mcp_config_test.go, mcp_adapter_test.go MCP integration
Deep research / web surfaces web_surfaces_test.go, research_store_test.go Deep research
Auth / Codex provider_auth_test.go, codex_*_test.go LLM layer — ChatGPT Sub
CI events cievents_test.go Runtime orchestration
Cursor cursor_paths_test.go, stream_cursor_tool_test.go, cursor_native_display_test.go Cursor integration
Local server server_runtime_test.go, desktop_config_test.go Local server
Updater updater_test.go, commands_update_test.go Supporting packages

Runtime-specific notes

When testing turn/cancel behavior:

  • User stop uses context.WithCancelCause and errUserStopGeneration (turns.go) — assert on errors.Is(context.Cause(ctx), ...) if you add cancel tests
  • Stream integrity rejection must not persist partial assistant content (stream_integrity_test.go)
  • Session mutation should go through runtime helpers / mutateSession, not raw races on Session in production code
  • Research status may be polled while its background engine is running; JobRecord values must be updated and returned as independent snapshots. Keep the regression covered by TestDeepResearchRuntimeUsesInternalWebAdapters and run it under -race.

Node sidecar tests

TypeScript unit tests live under integrations/cursor/test/. Run:

make cursor-proxy-test

Go tests cover the bridge and install paths; full Cursor SDK runs are not required in CI for most Go changes.

See also

Clone this wiki locally