Skip to main content

TestResult

Struct TestResult 

Source
pub struct TestResult<T> { /* private fields */ }
Expand description

Result of a durable execution test.

Contains the execution outcome, captured operations, and provides methods for inspecting and verifying workflow behavior.

§Type Parameters

  • T - The type of the successful result value

§Examples

use durable_execution_sdk_testing::{TestResult, ExecutionStatus};

// After running a test
let result: TestResult<String> = runner.run("input").await?;

// Check status
assert_eq!(result.get_status(), ExecutionStatus::Succeeded);

// Get the result value
let value = result.get_result()?;
assert_eq!(value, "expected output");

// Inspect operations
let ops = result.get_operations();
assert_eq!(ops.len(), 3);

Implementations§

Source§

impl<T> TestResult<T>

Source

pub fn success(result: T, operations: Vec<Operation>) -> Self

Creates a new successful TestResult.

Source

pub fn failure(error: TestResultError, operations: Vec<Operation>) -> Self

Creates a new failed TestResult.

Source

pub fn with_status(status: ExecutionStatus, operations: Vec<Operation>) -> Self

Creates a new TestResult with a specific status.

Source

pub fn set_result(&mut self, result: T)

Sets the result value.

Source

pub fn set_error(&mut self, error: TestResultError)

Sets the error.

Source

pub fn set_invocations(&mut self, invocations: Vec<Invocation>)

Sets the invocations.

Source

pub fn add_invocation(&mut self, invocation: Invocation)

Adds an invocation.

Source

pub fn set_history_events(&mut self, events: Vec<HistoryEvent>)

Sets the history events.

Source

pub fn add_history_event(&mut self, event: HistoryEvent)

Adds a history event.

Source

pub fn set_nodejs_history_events(&mut self, events: Vec<NodeJsHistoryEvent>)

Sets the Node.js SDK compatible history events.

These events match the Node.js SDK’s event history format exactly, enabling cross-SDK history comparison.

Source

pub fn add_nodejs_history_event(&mut self, event: NodeJsHistoryEvent)

Adds a Node.js SDK compatible history event.

Source

pub fn get_status(&self) -> ExecutionStatus

Gets the execution status.

§Returns

The current execution status (Succeeded, Failed, Running, etc.)

Source

pub fn get_result(&self) -> Result<&T, TestError>

Gets the result value if execution succeeded.

§Returns
  • Ok(&T) - Reference to the result value if execution succeeded
  • Err(TestError) - Error if execution failed or result is not available
Source

pub fn get_error(&self) -> Result<&TestResultError, &str>

Gets the error if execution failed.

§Returns
  • Ok(&TestResultError) - Reference to the error if execution failed
  • Err(&str) - Error message if execution succeeded or error is not available
Source

pub fn get_operations(&self) -> &[Operation]

Gets all operations from the execution.

§Returns

A slice of all operations captured during execution, in execution order.

Source

pub fn get_operations_by_status( &self, status: OperationStatus, ) -> Vec<&Operation>

Gets operations filtered by status.

§Arguments
  • status - The operation status to filter by
§Returns

A vector of references to operations matching the given status.

Source

pub fn get_invocations(&self) -> &[Invocation]

Gets handler invocation details.

§Returns

A slice of invocation details for each time the handler was invoked.

Source

pub fn get_history_events(&self) -> &[HistoryEvent]

Gets history events from the execution.

§Returns

A slice of history events that occurred during execution.

Source

pub fn get_nodejs_history_events(&self) -> &[NodeJsHistoryEvent]

Gets Node.js SDK compatible history events from the execution.

Returns events in the Node.js SDK compatible format, suitable for cross-SDK history comparison. These events use PascalCase field names and include detailed event-specific information.

§Returns

A slice of Node.js-compatible history events that occurred during execution.

Source

pub fn is_success(&self) -> bool

Checks if the execution succeeded.

Source

pub fn is_failure(&self) -> bool

Checks if the execution failed.

Source

pub fn is_running(&self) -> bool

Checks if the execution is still running.

Source

pub fn operation_count(&self) -> usize

Gets the number of operations.

Source

pub fn invocation_count(&self) -> usize

Gets the number of invocations.

Source§

impl<T> TestResult<T>

Source

pub fn print(&self)

Prints a formatted table of all operations to stdout.

Uses default column configuration showing name, type, status, and timing information.

Source

pub fn print_with_config(&self, config: PrintConfig)

Prints a formatted table of operations with custom column configuration.

§Arguments
  • config - Configuration specifying which columns to include
Source§

impl<T: DeserializeOwned> TestResult<T>

Source

pub fn deserialize_result_from_json(json: &str) -> Result<T, TestError>

Attempts to deserialize the result from a JSON string.

This is useful when the result was stored as a serialized string and needs to be deserialized into the expected type.

Trait Implementations§

Source§

impl<T: Clone> Clone for TestResult<T>

Source§

fn clone(&self) -> TestResult<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for TestResult<T>

Source§

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

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

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

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<T> Serialize for TestResult<T>
where T: Serialize,

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

Auto Trait Implementations§

§

impl<T> Freeze for TestResult<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for TestResult<T>
where T: RefUnwindSafe,

§

impl<T> Send for TestResult<T>
where T: Send,

§

impl<T> Sync for TestResult<T>
where T: Sync,

§

impl<T> Unpin for TestResult<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for TestResult<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for TestResult<T>
where T: UnwindSafe,

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<B> IntoFunctionResponse<B, Body> for B
where B: Serialize,

Source§

fn into_response(self) -> FunctionResponse<B, Body>

Convert the type into a FunctionResponse.
Source§

impl<Unshared, Shared> IntoShared<Shared> for Unshared
where Shared: FromUnshared<Unshared>,

Source§

fn into_shared(self) -> Shared

Creates a shared type from an unshared type.
Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T> DurableValue for T