la10736 / rstest

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

Inject case description? #200

Closed hillin closed 1 year ago

hillin commented 1 year ago

I'm imagining something like the #[case_desc] as demonstrated below could be helpful for debugging/tracing:

#[rstest]
#[case::foo(1)]
#[case::bar(2)]
fn test(#[case_desc] case_desc: &str, #[case] value: isize) {
  println!("Running test '{}', value = {}", case_desc, value);
  match value {
     1 => { assert_eq!("foo", case_desc); }
     2 => { assert_eq!("bar", case_desc); }
     _ => {}
  };
}
la10736 commented 1 year ago

Ok... is a good idea.I've already traced this issue in #177 . You can update it and close this ticket. I'm not sure if is better just narrow the syntax to the description as you proposed or a more general approach like #[context]... or even both.

hillin commented 1 year ago

Yeah, I think the #[context] approach is good enough for me.