Skip to main content

Crate aptitude

Crate aptitude 

Source
Expand description

§aptitude

A fluent assertion library for testing AI agent tool calls.

This library provides a Jest-like API for asserting on tool calls made by AI coding agents. It can be used with Rust’s native #[test] framework.

§Quick Start

use aptitude::{prompt, expect, Tool};

#[test]
fn test_agent_behavior() {
    let tool_calls = prompt("Read the config file").run().unwrap();

    expect(&tool_calls)
        .tool(Tool::Read)
        .to_be_called();

    expect(&tool_calls)
        .tool(Tool::Bash)
        .not_to_be_called();
}

§With Working Directory

use aptitude::{prompt, expect, Tool};

#[test]
fn test_in_project_dir() {
    let tool_calls = prompt("List files here")
        .in_dir("/path/to/project")
        .run()
        .unwrap();

    expect(&tool_calls)
        .tool(Tool::Bash)
        .to_be_called();
}

§Analyzing Existing Sessions

use aptitude::{parse_session, expect, Tool};

#[test]
fn test_existing_session() {
    let tool_calls = parse_session("session.jsonl").unwrap();

    expect(&tool_calls)
        .tool(Tool::Write)
        .after(Tool::Read);
}

Re-exports§

pub use fluent::expect;
pub use fluent::expect_tools;
pub use fluent::params_match;
pub use fluent::ExecutionExpectation;
pub use fluent::StdoutAssertion;
pub use fluent::ToolAssertion;
pub use parser::parse_jsonl_file as parse_session;
pub use parser::ToolCall;
pub use fluent::Tool;
pub use agents::AgentHarness;
pub use agents::AgentType;
pub use agents::ExecutionConfig;
pub use agents::ExecutionOutput;
pub use agents::NormalizedResult;
pub use prompt::prompt;
pub use prompt::PromptBuilder;
pub use output::OutputConfig;
pub use output::OutputFormatter;
pub use output::OutputMode;
pub use yaml::load_test;
pub use yaml::run_yaml_test;
pub use yaml::Assertion;
pub use yaml::Test as YamlTest;

Modules§

agents
Agent abstraction layer for multi-agent support.
config
Configuration file support for aptitude.
discovery
Test file discovery using glob patterns and walkdir.
fluent
Fluent assertion API for testing AI agent execution output.
output
Output formatting for test results, tool calls, and agent responses.
parser
prompt
Prompt builder for fluent prompt configuration and execution.
yaml
YAML test file support for the agent harness.

Macros§

params
Create a parameter map from key-value pairs.