Skip to main content

TestCase

Struct TestCase 

Source
pub struct TestCase {
    pub name: String,
    pub skill: PathBuf,
    pub input: String,
    pub user: Option<SimulatedUser>,
    pub mocks: Vec<MockDecl>,
    pub spy: bool,
    pub evals: Vec<Eval>,
}
Expand description

One test case.

This type is the source of truth for the input contract (schemas/case.schema.json): the shape a --case-json payload — and the SDKs’ generated case models — must have. Serialization skips absent/default fields so the canonical JSON form is minimal; the SDK case builders emit that same form (pinned by the kitchen-sink golden in tests/fixtures/contract/).

Fields§

§name: String

Human-readable name (defaults to the file stem when loaded from a file).

§skill: PathBuf

Path to the skill directory under test, relative to the test-case file.

§input: String

The initial data/prompt handed to the skill as the first user message.

§user: Option<SimulatedUser>

Present for multi-turn cases; absent for single-turn.

§mocks: Vec<MockDecl>

Mock/spy declarations for this case: a declaration with a stub/deny/ rewrite action intercepts matching tool calls; one without observes only. called/not_called evals reference these by name.

§spy: bool

Record every tool call through the mock/spy channel even with no mocks declared, so code-level consumers (the SDKs’ spies) get records. Implied whenever mocks is non-empty.

§evals: Vec<Eval>

The evals that decide whether this case passes. Must be non-empty.

Implementations§

Source§

impl TestCase

Source

pub fn load(path: &Path) -> Result<Self>

Load a test case from a YAML file. The name defaults to the file stem and skill is resolved relative to the file’s directory.

§Errors

Error::Io if the file cannot be read, Error::Yaml on parse failure, and Error::Invalid if the case is internally inconsistent.

Source

pub fn from_json(json: &str, base_dir: &Path) -> Result<Vec<Self>>

Parse one or more fully-specified test cases from JSON — a single case object or an array — the shape the language SDKs emit when a case is built in code rather than written as YAML (skilltest run --case-json).

Unlike load these cases have no source file, so each is finalized against base_dir (typically the working directory): a relative skill resolves there, and an unnamed case defaults to case (suffixed with its index when several are unnamed, keeping report keys distinct).

§Errors

Error::Invalid if the JSON does not parse into test cases, or if any case is internally inconsistent.

Source

pub fn finalize(&mut self, base_dir: &Path, default_name: &str) -> Result<()>

Finalize an in-memory case: default name to default_name when unset, resolve a relative skill against base_dir, and validate. Shared by load (anchored at the file’s directory) and from_json (anchored at the working directory, since a code-defined case has no file).

§Errors

Error::Invalid if the case is internally inconsistent.

Source

pub fn is_multi_turn(&self) -> bool

Whether this is a multi-turn case (has a simulated user).

Source

pub fn validate(&self) -> Result<()>

Validate the case’s structure and every eval.

§Errors

Error::Invalid when input/evals are empty or an eval is malformed.

Trait Implementations§

Source§

impl Clone for TestCase

Source§

fn clone(&self) -> TestCase

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TestCase

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for TestCase

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl JsonSchema for TestCase

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for TestCase

Source§

fn eq(&self, other: &TestCase) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for TestCase

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for TestCase

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.