Skip to main content

ExecutionError

Enum ExecutionError 

Source
#[non_exhaustive]
pub enum ExecutionError { Skip { message: Option<String>, }, StepNotFound { index: usize, keyword: StepKeyword, text: String, feature_path: String, scenario_name: String, }, MissingFixtures(Arc<MissingFixturesDetails>), HandlerFailed { index: usize, keyword: StepKeyword, text: String, error: Arc<StepError>, feature_path: String, scenario_name: String, }, }
Expand description

Error type for step execution failures.

This enum captures all failure modes during step execution, distinguishing between control flow signals (skip requests) and actual errors (missing steps, fixture validation failures, handler errors).

§Variants

  • Skip: Control flow signal indicating the step requested skipping. This is not an error condition but a deliberate execution path.
  • StepNotFound: The step pattern was not found in the registry.
  • MissingFixtures: Required fixtures were not available in the context.
  • HandlerFailed: The step handler returned an error.

§Examples

use rstest_bdd::execution::ExecutionError;

let error = ExecutionError::Skip { message: Some("not implemented yet".into()) };
assert!(error.is_skip());
assert_eq!(error.skip_message(), Some("not implemented yet"));

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Skip

Step requested to skip execution.

Fields

§message: Option<String>

Optional message explaining why the step was skipped.

§

StepNotFound

Step pattern not found in the registry.

Fields

§index: usize

Zero-based step index.

§keyword: StepKeyword

The step keyword (Given, When, Then, etc.).

§text: String

The step text that was not found.

§feature_path: String

Path to the feature file.

§scenario_name: String

Name of the scenario.

§

MissingFixtures(Arc<MissingFixturesDetails>)

Required fixtures missing from context.

The details are wrapped in Arc to reduce the size of Result<T, ExecutionError>.

§

HandlerFailed

Step handler returned an error.

Fields

§index: usize

Zero-based step index.

§keyword: StepKeyword

The step keyword (Given, When, Then, etc.).

§text: String

The step text.

§error: Arc<StepError>

The error returned by the handler, wrapped in Arc for Clone.

§feature_path: String

Path to the feature file.

§scenario_name: String

Name of the scenario.

Implementations§

Source§

impl ExecutionError

Source

pub fn is_skip(&self) -> bool

Returns true if this error represents a skip request.

Skip requests are control flow signals, not actual errors. Use this method to distinguish between errors that should fail a test and skip signals that should mark the test as skipped.

§Examples
use rstest_bdd::execution::ExecutionError;

let skip = ExecutionError::Skip { message: None };
assert!(skip.is_skip());

let not_found = ExecutionError::StepNotFound {
    index: 0,
    keyword: rstest_bdd::StepKeyword::Given,
    text: "missing".into(),
    feature_path: "test.feature".into(),
    scenario_name: "test".into(),
};
assert!(!not_found.is_skip());
Source

pub fn skip_message(&self) -> Option<&str>

Returns the skip message if this is a skip error.

Returns None if this is not a skip error, or if the skip has no message.

§Examples
use rstest_bdd::execution::ExecutionError;

let skip_with_msg = ExecutionError::Skip { message: Some("reason".into()) };
assert_eq!(skip_with_msg.skip_message(), Some("reason"));

let skip_no_msg = ExecutionError::Skip { message: None };
assert_eq!(skip_no_msg.skip_message(), None);

let not_skip = ExecutionError::StepNotFound {
    index: 0,
    keyword: rstest_bdd::StepKeyword::Given,
    text: "missing".into(),
    feature_path: "test.feature".into(),
    scenario_name: "test".into(),
};
assert_eq!(not_skip.skip_message(), None);
Source§

impl ExecutionError

Source

pub fn format_with_loader(&self, loader: &FluentLanguageLoader) -> String

Render the error message using the provided Fluent loader.

This allows formatting the error using a specific locale loader rather than the global default. This is useful when you need consistent locale handling across nested error types.

§Examples
use i18n_embed::fluent::fluent_language_loader;
use unic_langid::langid;
use rstest_bdd::execution::ExecutionError;

let loader = {
    use i18n_embed::LanguageLoader;
    use rstest_bdd::Localizations;
    let loader = fluent_language_loader!();
    i18n_embed::select(&loader, &Localizations, &[langid!("en-US")])
        .expect("en-US locale should always be available");
    loader
};
let error = ExecutionError::Skip { message: Some("not implemented".into()) };
let message = error.format_with_loader(&loader);
assert!(message.contains("skipped"));
assert!(message.contains("not implemented"));

Trait Implementations§

Source§

impl Clone for ExecutionError

Source§

fn clone(&self) -> ExecutionError

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 Debug for ExecutionError

Source§

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

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

impl Display for ExecutionError

Source§

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

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

impl Error for ExecutionError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more

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> 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> 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.