la10736 / rstest

Fixture-based test framework for Rust
Apache License 2.0
1.21k stars 43 forks source link

destructure fixture type in template #273

Open SET001 opened 2 months ago

SET001 commented 2 months ago

There is #[from(...)] attribute to destructure fixture type. Should it work with rstest_reuse? If yes then how? Here is my attempt and it does not work

fn foo() -> (usize, usize) {
  (1, 1)
}

#[template]
#[rstest]
#[case(foo(), 0, 1)]
fn remove_test_cases(
  #[case] input: (usize, usize),
  #[case] to_remove: usize,
  #[case] expect: usize,
) {}

#[apply(remove_test_cases)]
fn when_component_removed(
  #[from(input)] (one, two): (usize, usize),
  to_remove: usize,
  expect: usize,
) {}

the error is

Wrong case signature: should match the given parameters list.
la10736 commented 2 months ago

I'm sorry. In rstest_rreuse destruct support is not implemented yet.

Just as note, the relevant code to change is https://github.com/la10736/rstest/blob/e65e927ccea909789dc2ac1deb290119f816fac3/rstest_reuse/src/lib.rs#L253-L259