Skip to main content

TestId

Trait TestId 

Source
pub trait TestId:
    Copy
    + Debug
    + 'static {
    // Required methods
    fn test_id(&self) -> Cow<'static, str>;
    fn rust_path(&self) -> &'static str;

    // Provided method
    fn qualified_path(&self) -> &'static str { ... }
}
Expand description

A test id the view and the tests name with the same value, so a typo does not compile.

Derive it on an enum with #[derive(TestId)]: unit variants become their name in kebab case, and #[test_id("delete-{0}")] sets a string or a format string over the fields.

Required Methods§

Source

fn test_id(&self) -> Cow<'static, str>

The string written into the tree.

Source

fn rust_path(&self) -> &'static str

The Rust path of the variant, such as Ids::Delete, for error messages and the recorder’s output.

Provided Methods§

Source

fn qualified_path(&self) -> &'static str

The variant’s path from its crate root, such as todo::ui::Ids::Delete, which the raw tree reports so the recorder can name the variant from a test. The derive builds it with module_path!(); an impl written by hand gives rust_path.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§