Testing Guide
Merlon has tests at every layer: Go and TypeScript. This document covers how to run each and the overall testing strategy.
Running tests per component
Go (API)
cd api && go test ./...
With coverage:
cd api && go test -cover ./...
UI (TypeScript / React)
cd ui && npm run test
Running everything
make test
make test runs the Go and UI tests. CI uses the same target.
Testing strategy (TDD)
Feature work and bug fixes follow TDD (test-driven development).
- Write the test — write a test that expresses the expected behavior first (confirm it fails).
- Implement — write the minimal code needed to make the test pass.
- Refactor — clean up while keeping the test green.
Emphasis by layer
- Native engine (Go) — CDD scoring, TM evaluation, screening, and backtesting are the core business logic. To uphold reproducibility of decision rationale (Auditability First), tests pin the determinism of output for identical input.
- API (Go) — CRUD and orchestration. Tests verify service-boundary contracts and that failures fall toward alerting rather than silence (Fail-Alert).
- UI — component-level tests plus user-flow tests for the investigation workflow.
Follow existing patterns
New tests should follow the existing test framework, naming conventions, and
patterns in each directory. Go uses the standard testing package, and the UI
follows its existing test-runner configuration.