Skip to main content

explicit_test_case

Attribute Macro explicit_test_case 

Source
#[explicit_test_case]
Expand description

Define an explicit test case to run before the property-based test.

Note: We are not currently 100% happy with the name of this attribute and expect that we might change it in future. The API should otherwise remain compatible, but you might have to rename some call-sites.

Must be placed below #[hegel::test]. Multiple attributes are allowed.

#[hegel::test]
#[hegel::explicit_test_case(x = 42, y = "hello")]
fn my_test(tc: hegel::TestCase) {
    let x: i32 = tc.draw(hegel::generators::integers());
    let y: String = tc.draw(hegel::generators::text());
    // ...
}

Arguments correspond to the names they would be printed with in a failing test case, so need suffixing if they’re repeated. For example:

#[hegel::test]
#[hegel::explicit_test_case(x_1 = 1, x_2 = 2, x_3 = 4 )]
fn my_test(tc: hegel::TestCase) {
    for _ in 0..3 {
        let x: i32 = tc.draw(hegel::generators::integers());
    }
}