Skip to main content

Testing Guide

Station has comprehensive test coverage across unit, integration, and end-to-end tests.

Running Tests

All Tests

Specific Packages

Test Coverage

Current test coverage: ~52.7%

Test Structure

Writing Tests

Unit Test Pattern

Table-Driven Tests

Station uses table-driven tests extensively:

Mocking

Station uses interfaces for testability. Generate mocks with:
Example mock usage:

Integration Tests

Integration tests use real databases and services:
Run integration tests:

API Tests

Database Tests

Test Helpers

Test Database Setup

Test Fixtures

Continuous Integration

Tests run automatically on:
  • Every push to main
  • Every pull request
  • Release tag creation
CI configuration runs:

Testing Best Practices

  1. Test behavior, not implementation - Focus on what the code does, not how
  2. Use table-driven tests - Makes adding test cases easy
  3. Mock at boundaries - Mock external services, not internal code
  4. Keep tests fast - Use in-memory databases, skip slow tests with -short
  5. Test error cases - Ensure errors are handled correctly
  6. Clean up resources - Use defer for cleanup
  7. Use meaningful names - Test names should describe the scenario

Next Steps

Code Style

Coding conventions and standards

Architecture

Understanding the codebase structure