Skip to main content
Goose has a comprehensive test suite covering unit tests, integration tests, and MCP extension tests. This guide explains how to write and run tests.

Running Tests

All Tests

Run the entire test suite:

Specific Crate

Test a single crate:

Specific Test

Run a specific test by name:

MCP Integration Tests

Run MCP tests with replay recording:
This runs tests and records MCP interactions to crates/goose/tests/mcp_replays/.

UI Tests

Test the desktop UI:

Test Organization

Unit Tests

Unit tests live alongside the code they test:

Integration Tests

Integration tests are in dedicated tests/ directories:
Integration tests can import from the crate:

Writing Tests

Basic Test Structure

Async Tests

Use #[tokio::test] for async tests:

Test Case Macro

Use test_case for parameterized tests:

Testing Providers

Create a mock provider for testing:

MCP Integration Testing

MCP tests verify extension behavior (crates/goose/tests/mcp_integration_test.rs).

Test Structure

Recording MCP Interactions

Set GOOSE_RECORD_MCP=1 to record interactions:
Recorded interactions are saved to crates/goose/tests/mcp_replays/ and can be used for regression testing.

Test Utilities

goose-test Crate

Provides utilities for testing:

goose-test-support Crate

Helpers for integration tests:

Testing Extensions

Extension Test Pattern

Testing Best Practices

Prefer Integration Tests

Per project guidelines, prefer tests in tests/ directories:

Update Self-Test Recipe

When adding features, update goose-self-test.yaml:

Use Anyhow for Tests

Test functions can return Result<()>:

Avoid Flaky Tests

  • Don’t rely on timing/sleep
  • Use deterministic test data
  • Mock external dependencies
  • Clean up resources in tests

Test Coverage

Aim to test:
  • Happy path functionality
  • Error cases
  • Edge cases (empty input, large input, etc.)
  • Async behavior and cancellation
  • Resource cleanup

Continuous Integration

Tests run on every PR via GitHub Actions (.github/workflows/ci.yml). Locally, run the same checks:
This runs:
  • cargo fmt - Code formatting
  • cargo clippy - Linting
  • cargo test - All tests
  • UI linting
  • OpenAPI schema validation

Debugging Tests

Show Test Output

Run Single Test

Enable Logging

Filter Tests

Performance Testing

Local inference performance tests:

Next Steps