Start

Testing Guide

This document defines the testing policy and workflows for the START project.

Core Principles

Flow

Test Structure

Unit Tests

Script & Integration Tests

Running Tests

# Full suite
uv run pytest -q

# Verbose / coverage
uv run pytest -v
uv run pytest --cov=src --cov-report=html

# Focused runs
uv run pytest -k "domain"
uv run pytest tests/test_domain.py

Markers

Gate network tests behind CI:

import os
import pytest

RUN_NETWORK = os.getenv("CI") == "true"


network = pytest.mark.network


def skip_network_if_disallowed():
    if not RUN_NETWORK:
        pytest.skip("Network tests disabled outside CI")


@network
def test_network_feature():
    skip_network_if_disallowed()
    # real network call here

Offline-First Testing

def test_file_processing(tmp_path):
    source = tmp_path / "input.json"
    source.write_text('{"a": 1}')
    result = process_file(source)
    assert result["a"] == 1

Environment Setup for Tests

# Non-GUI matplotlib backend
export MPLBACKEND=Agg

# Optional: keys for CI network tests
export PERPLEXITY_API_KEY="..."
export OPENROUTER_API_KEY="..."

Coverage

uv run pytest --cov=src --cov-report=html

Best Practices