pub struct TestCases { /* private fields */ }Expand description
Entry point for running tests
Implementations§
source§impl TestCases
 
impl TestCases
pub fn new() -> Self
sourcepub fn interrupted(&self, glob: impl AsRef<Path>) -> &Self
 
pub fn interrupted(&self, glob: impl AsRef<Path>) -> &Self
Overwrite expected status for a test
sourcepub fn default_bin_path(&self, path: impl AsRef<Path>) -> &Self
 
pub fn default_bin_path(&self, path: impl AsRef<Path>) -> &Self
Set default bin, by path, for commands
sourcepub fn default_bin_name(&self, name: impl AsRef<str>) -> &Self
 
pub fn default_bin_name(&self, name: impl AsRef<str>) -> &Self
Set default bin, by name, for commands
sourcepub fn env(&self, key: impl Into<String>, value: impl Into<String>) -> &Self
 
pub fn env(&self, key: impl Into<String>, value: impl Into<String>) -> &Self
Set default environment variable
sourcepub fn register_bin(&self, name: impl Into<String>, path: impl Into<Bin>) -> &Self
 
pub fn register_bin(&self, name: impl Into<String>, path: impl Into<Bin>) -> &Self
Add a bin to the “PATH” for cases to use
sourcepub fn register_bins<N: Into<String>, B: Into<Bin>>(
    &self,
    bins: impl IntoIterator<Item = (N, B)>
) -> &Self
 
pub fn register_bins<N: Into<String>, B: Into<Bin>>(
    &self,
    bins: impl IntoIterator<Item = (N, B)>
) -> &Self
Add a series of bins to the “PATH” for cases to use
sourcepub fn insert_var(
    &self,
    var: &'static str,
    value: impl Into<Cow<'static, str>>
) -> Result<&Self, Error>
 
pub fn insert_var(
    &self,
    var: &'static str,
    value: impl Into<Cow<'static, str>>
) -> Result<&Self, Error>
Add a variable for normalizing output
Variable names must be
- Surrounded by []
- Consist of uppercase letters
Variables will be preserved through TRYCMD=overwrite / TRYCMD=dump.
NOTE: We do basic search/replaces so new any new output will blindly be replaced.
Reserved names:
- [..]
- [EXE]
- [CWD]
- [ROOT]
Example
#[test]
fn cli_tests() {
    trycmd::TestCases::new()
        .case("tests/cmd/*.trycmd")
        .insert_var("[VAR]", "value");
}sourcepub fn extend_vars(
    &self,
    vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)>
) -> Result<&Self, Error>
 
pub fn extend_vars(
    &self,
    vars: impl IntoIterator<Item = (&'static str, impl Into<Cow<'static, str>>)>
) -> Result<&Self, Error>
Batch add variables for normalizing output
See insert_var.