Skip to main content

Quick Start

Run All Tests

No external database required - tests use embedded libSQL by default.

Run Tests with Logging

Run Specific Tests

Test Categories

Unit Tests

Unit tests are located in the same file as the code they test:
Run unit tests:

Integration Tests

Integration tests are in the tests/ directory:
Run integration tests:

Feature-Gated Tests

Some tests require specific features:

Database Testing

libSQL (Default)

Tests use embedded libSQL by default - no setup required:
Each test gets a temporary database that’s automatically cleaned up.

PostgreSQL Integration Tests

For PostgreSQL-specific tests:
Set the test database URL:

Test Containers

Some integration tests use testcontainers for PostgreSQL:
Docker will automatically start a PostgreSQL container for testing.

Test Organization

Module Tests

Tests in the same file as the code:

Separate Test Files

Large test suites in tests/:

Writing Tests

Basic Test Structure

Async Tests

Testing Errors

Testing with Mock Data

Snapshot Testing

IronClaw uses insta for snapshot testing:
Update snapshots:

Test Utilities

Test Fixtures

Create reusable test data:

Pretty Assertions

For better diff output:

Running Specific Test Suites

All Tests

Library Tests Only

Integration Tests Only

Doc Tests

Benchmarks

All Targets

Test Configuration

Parallel Execution

Test Timeout

Ignore Tests

Run ignored tests:

Coverage

Install Coverage Tool

Generate Coverage Report

Coverage with Specific Features

CI Coverage

Continuous Integration

GitHub Actions

IronClaw uses GitHub Actions for CI:

Local CI Testing

Run the same tests as CI:

Benchmarking

Criterion Benchmarks

For performance testing:
Run benchmarks:

Debugging Tests

Run with Debugger

Run with output:

Conditional Logging

Best Practices

Test Naming

Arrange-Act-Assert Pattern

Test Independence

Each test should be independent:

Use Test Helpers

Common Test Patterns

Testing Result Types

Testing Option Types

Testing Panics

Troubleshooting

Test Database Conflicts

Issue: Tests fail due to database conflicts Solution: Use isolated test databases

Flaky Tests

Issue: Tests pass/fail intermittently Solutions:
  • Check for race conditions
  • Use proper synchronization
  • Avoid time-dependent tests
  • Make tests deterministic

Slow Tests

Issue: Test suite takes too long Solutions:

Next Steps

Resources