pub enum StepKeyword {
Given,
When,
Then,
And,
But,
}Expand description
Keyword used to categorise a step definition.
The enum includes And and But variants for completeness, but feature
parsing resolves them against the preceding Given/When/Then using
the resolve method.
Variants§
Given
Setup preconditions for a scenario.
When
Perform an action when testing behaviour.
Then
Assert the expected outcome of a scenario.
And
Additional conditions that share context with the previous step.
But
Negative or contrasting conditions.
Implementations§
Source§impl StepKeyword
impl StepKeyword
Sourcepub const fn as_str(&self) -> &'static str
pub const fn as_str(&self) -> &'static str
Return the keyword as a string slice.
§Examples
use rstest_bdd_patterns::StepKeyword;
assert_eq!(StepKeyword::Given.as_str(), "Given");
assert_eq!(StepKeyword::And.as_str(), "And");Sourcepub fn resolve(self, prev: &mut Option<StepKeyword>) -> StepKeyword
pub fn resolve(self, prev: &mut Option<StepKeyword>) -> StepKeyword
Resolve conjunctions to the semantic keyword of the previous step.
When the current keyword is And or But, returns the value stored in
prev. For primary keywords (Given/When/Then), updates prev and
returns the keyword unchanged.
Callers typically seed prev with the first primary keyword in a
sequence, defaulting to Given when none is found.
§Examples
use rstest_bdd_patterns::StepKeyword;
let mut prev = Some(StepKeyword::Given);
assert_eq!(StepKeyword::And.resolve(&mut prev), StepKeyword::Given);
assert_eq!(StepKeyword::When.resolve(&mut prev), StepKeyword::When);
assert_eq!(prev, Some(StepKeyword::When));Trait Implementations§
Source§impl Clone for StepKeyword
impl Clone for StepKeyword
Source§fn clone(&self) -> StepKeyword
fn clone(&self) -> StepKeyword
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for StepKeyword
impl Debug for StepKeyword
Source§impl FromStr for StepKeyword
impl FromStr for StepKeyword
Source§type Err = StepKeywordParseError
type Err = StepKeywordParseError
Source§fn from_str(value: &str) -> Result<StepKeyword, <StepKeyword as FromStr>::Err>
fn from_str(value: &str) -> Result<StepKeyword, <StepKeyword as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Hash for StepKeyword
impl Hash for StepKeyword
Source§impl PartialEq for StepKeyword
impl PartialEq for StepKeyword
Source§impl TryFrom<&str> for StepKeyword
impl TryFrom<&str> for StepKeyword
Source§type Error = StepKeywordParseError
type Error = StepKeywordParseError
Source§fn try_from(
value: &str,
) -> Result<StepKeyword, <StepKeyword as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<StepKeyword, <StepKeyword as TryFrom<&str>>::Error>
Source§impl TryFrom<StepType> for StepKeyword
impl TryFrom<StepType> for StepKeyword
Source§fn try_from(
ty: StepType,
) -> Result<StepKeyword, <StepKeyword as TryFrom<StepType>>::Error>
fn try_from( ty: StepType, ) -> Result<StepKeyword, <StepKeyword as TryFrom<StepType>>::Error>
Convert a parsed Gherkin StepType to a StepKeyword.
§Gherkin coupling
The gherkin crate (v0.14) defines StepType with only Given, When,
and Then variants. Gherkin syntax also includes And and But
keywords, but the parser resolves these to the preceding primary keyword
before exposing them via StepType.
If a future gherkin release adds new StepType variants (e.g., And,
But, or others), the #[expect(unreachable_patterns)] guard below will
trigger a compiler warning, prompting an update to this match arm.
Source§type Error = UnsupportedStepType
type Error = UnsupportedStepType
impl Copy for StepKeyword
impl Eq for StepKeyword
impl StructuralPartialEq for StepKeyword
Auto Trait Implementations§
impl Freeze for StepKeyword
impl RefUnwindSafe for StepKeyword
impl Send for StepKeyword
impl Sync for StepKeyword
impl Unpin for StepKeyword
impl UnwindSafe for StepKeyword
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.