Module testing

Module testing 

Source
Expand description

Testing utilities — a mock model, agent harnesses, contract validation.

Test an agent without a provider by building it on MockLlm and asserting on both what it returned and what it sent:

use gemini_adk_fluent_rs::prelude::*;
use gemini_adk_fluent_rs::testing::{LlmResponse, MockLlm};

let llm = MockLlm::script([LlmResponse::from_text("Paris.")]);
let agent = AgentBuilder::new("geo")
    .instruction("Answer with a city.")
    .build(llm.clone())
    .unwrap();

let state = State::new();
state.set("input", "Capital of France?").unwrap();
assert_eq!(agent.run(&state).await.unwrap(), "Paris.");

let sent = llm.last_request().unwrap();
assert_eq!(sent.system_instruction.as_deref(), Some("Answer with a city."));

Structs§

AgentHarness
A test harness for running agents with controlled inputs.
DataFlowEdge
A data flow edge between two agents.
FileTape
A tape kept in a JSONL file, one TapeEntry per line.
LlmRequest
Configuration for an LLM generation request.
LlmResponse
The response from an LLM generation request.
ManualClock
A clock that moves only when told to.
MemoryTape
A tape held in memory.
MockLlm
A BaseLlm that replies from a script or a closure and records every request, for tests that must not reach a provider.
ScriptedRun
The outcome of ScriptedServer::play.
ScriptedServer
A scripted Gemini Live server, for testing a Live session offline.
SystemClock
The real clock: Instant::now and SystemTime::now.
TapeEntry
One recorded call: what went in and what came out.
TapedLlm
A BaseLlm that records its calls to a Tape or answers them from one. See the module docs.
TokenUsage
Token usage statistics.

Enums§

ContractViolation
Contract violation detected during static analysis.
LiveViolation
A misconfiguration found in a Live builder, before connecting.
TapeMode
Whether a taped_resolver records calls or answers them from the tape.

Traits§

Clock
A source of monotonic and wall-clock time.
Tape
Where recorded calls are kept.

Functions§

check_contracts
Check state contracts across a set of agents.
check_live
Statically check a configured Live session.
diagnose
Diagnostic utility — returns a summary of an agent builder’s configuration.
infer_data_flow
Infer data flow between agents based on reads/writes declarations.
taped_resolver
Wrap a resolver’s fetch so its calls are recorded on, or answered from, tape.

Type Aliases§

SharedClock
A shared, dynamically dispatched clock.