Skip to content

Test case macro should not rely on implementation details of the built-in test framework #131

@mzabaluev

Description

@mzabaluev

It seems the test_case attribute can only work as a hack of the built-in test framework rather than an "honest" attribute macro.
In particular, this fails:

use test_case::test_case as parametric_test;

#[parametric_test(1 ; "one")]
#[parametric_test(2 ; "two")]
#[parametric_test(3 ; "three")]
fn test_blubbi(x: u32) {
}

The built-in use of test_case is not documented and should probably be treated as unstable. The built-in attribute certainly is unstable, so overriding it with use test_case::test_case is a hack that is liable to stop working in any future release of Rust.
Also, this does not work as intended:

use test_case::test_case;
mod foo {
    use super::*;

    #[test_case(1 ; "one")]
    #[test_case(2 ; "two")]
    #[test_case(3 ; "three")]
    fn test_blubbi(x: u32) {
        // test logic that uses x: {1,2,3} * T: {Foo, Bar} thus 6 test cases in total
    }
}

This impedes interoperability with another boilerplate-reducing solution for tests: mzabaluev/generic-tests#6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions