Testing Guide banner
digitalocean-labs digitalocean-labs

Testing Guide

Testing community intermediate

Description

This guide covers how to run, write, and maintain tests for the DO App Platform Skills repository.

Installation

This entry records only its repository, not the path inside it, so there is no exact command to give. Open the source below and copy the folder into ~/.claude/skills/, or the file into ~/.claude/agents/.

Repository README

This is the README for digitalocean-labs/do-app-platform-skills, shared by 3 entries in this directory. It describes the repository, not this entry specifically.

Testing Guide

This guide covers how to run, write, and maintain tests for the DO App Platform Skills repository.

Quick Start

# Install dependencies
make install

# Run all tests
make test

# Run with coverage
make test-cov

# Run specific test categories
make test-unit
make test-integration
make test-security

Test Organization

Test Structure

tests/
├── conftest.py              # Shared fixtures and configuration
├── test_helpers.py          # Test utility functions
├── test_migration/          # Migration script tests
├── test_postgres/           # PostgreSQL script tests
├── test_shared/             # Shared configuration tests
├── test_validation/         # Schema and doc validation tests
├── test_workflows/          # End-to-end workflow tests
├── test_edge_cases/         # Error handling tests
└── test_security/           # Security tests

Test Categories (Markers)

Tests are organized using pytest markers:

  • @pytest.mark.unit - Fast, isolated unit tests
  • @pytest.mark.integration - Integration tests (may need external resources)
  • @pytest.mark.security - Security-focused tests
  • @pytest.mark.validation - Configuration/schema validation tests
  • @pytest.mark.e2e - End-to-end workflow tests
  • @pytest.mark.slow - Slow-running tests
  • @pytest.mark.requires_network - Tests requiring internet
  • @pytest.mark.requires_db - Tests requiring database connection

Running Tests

Basic Commands

# Run all tests
pytest

# Run with verbose output
pytest -v

# Run specific test file
pytest tests/test_migration/test_detect_platform.py

# Run specific test class
pytest tests/test_migration/test_detect_platform.py::TestPlatformDetector

# Run specific test
pytest tests/test_migration/test_detect_platform.py::TestPlatformDetector::test_detects_heroku_from_procfile

Using Markers

# Run only unit tests
pytest -m unit

# Run only integration tests
pytest -m integration

# Run security tests
pytest -m security

# Exclude slow tests
pytest -m "not slow"

# Run multiple categories
pytest -m "unit or integration"

Coverage Reports

# Generate coverage report
pytest --cov=skills --cov-report=term-missing

# Generate HTML coverage report
pytest --cov=skills --cov-report=html
open htmlcov/index.html

# Generate XML coverage (for CI)
pytest --cov=skills --cov-report=xml

Using Make Commands

make help           # Show all available commands
make test           # Run all tests
make test-cov       # Run tests with coverage
make test-html      # Run tests and open HTML coverage report
make test-unit      # Run unit tests only
make test-fast      # Skip slow tests
make clean          # Clean up generated files

Writing Tests

Test Naming Convention

  • Test files: test_*.py
  • Test classes: Test*
  • Test functions: test_*
# tests/test_migration/test_my_feature.py

@pytest.mark.unit
class TestMyFeature