Testing
ELMOS uses Go’s testing framework with mocks for infra.
Structure
Section titled “Structure”- Unit tests in
*_test.gofiles - Mocks in
core/infra/*/mock.go - Table-driven tests for commands
Running Tests
Section titled “Running Tests”task test # Run all teststask test:cover # With coverage reportMocking
Section titled “Mocking”Infra interfaces mocked for domain testing:
type MockExecutor struct { RunFunc func(cmd string, args ...string) error // ...}
func (m *MockExecutor) Run(cmd string, args ...string) error { return m.RunFunc(cmd, args...)}Used in domain tests to verify calls.
Coverage
Section titled “Coverage”Target: 80%+ coverage. Generated via go test -cover.
Integration Tests
Section titled “Integration Tests”Limited; focus on unit tests. Manual testing for full workflows.
Tests run on PRs and pushes.
Best Practices
Section titled “Best Practices”- Test public APIs
- Mock external deps
- Use
assertfor checks - Table-driven for multiple cases