Skip to main content

Feature

Struct Feature 

Source
pub struct Feature { /* private fields */ }
Expand description

Declare what a file’s scenarios are for, ahead of the examples.

Scenarios say what the system does. A declaration says why the feature exists and who it serves, so a reader meets the intent before the examples.

Reach for declare_feature! rather than calling this directly: Rust has no portable way to run code before a test binary’s tests, so the macro wraps the declaration in a #[test] of its own.

use executable_stories::Feature;

Feature::new("Anyone can do arithmetic without a calculator app")
    .ability()
    .narrative("Switching apps for a quick sum loses your place.")
    .term("operand", "One of the two numbers an operation is applied to.")
    .declare(file!());

Implementations§

Source§

impl Feature

Source

pub fn new(title: &str) -> Self

Start a declaration with the heading readers will see.

Source

pub fn ability(self) -> Self

Frame the feature as something a person can now do.

Source

pub fn business_need(self) -> Self

Frame the feature as a cross-cutting concern nobody asks for by name, such as security or performance.

Source

pub fn narrative(self, narrative: &str) -> Self

Explain, in markdown, why the feature exists and who it serves.

Source

pub fn tags(self, tags: &[&str]) -> Self

Apply tags to every scenario in the file.

Source

pub fn term(self, term: &str, definition: &str) -> Self

Define a term the scenarios use.

Source

pub fn declare(self, source_file: &str)

Record the declaration against a source file. Pass file!().

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.