Open arlyon opened 8 months ago
Thanks for the suggestion.
Considering just ignoring an individual test case in Yare, I've been trying out some syntactic ideas:
ignore(...)
#[parameterized(
ignore(apple = { Fruit::Apple, "apple" }),
pear = { Fruit::Pear, "pear" },
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
Advantages:
Disadvantages:
#
#[parameterized(
# apple = { Fruit::Apple, "apple" }),
# pear = {
Fruit::Pear, "pear"
},
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
Advantages:
Disadvantages:
#
on every test case line or for example require the first line and be optional on all others`:#[parameterized(
# pear = {
# Fruit::Pear, "pear"
# },
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
#ignore
#[parameterized(
#ignore apple = { Fruit::Apple, "apple" }),
#ignore pear = {
Fruit::Pear, "pear"
},
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
Let the #
act like a tag.
Extra advantage:
#ignore(cfg(target=windows))
(or #ignore(target=windows))#[parameterized(
#ignore(target=windows) apple = { Fruit::Apple, "apple" }),
#ignore(target=windows) pear = {
Fruit::Pear, "pear"
},
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
#[parameterized(
apple = { Fruit::Apple, "apple" }) #ignore(target=windows),
pear = {
Fruit::Pear, "pear"
} #ignore(target=windows),
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
#[parameterized(
apple = { Fruit::Apple, "apple" }).ignore(target=windows),
pear = {
Fruit::Pear, "pear"
}.ignore(target=windows),
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
Inspired by .await
#[parameterized(
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
_ignore = {
apple = { Fruit::Apple, "apple" }),
pear = {
Fruit::Pear, "pear"
},
}
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
A disadvantage:
_ignore
either disallowed or requiring some extra syntax like \_ignore
#[parameterized(
blackberry = { Fruit::Bramble(BrambleFruit::Blackberry), "blackberry" },
_ignore(cfg(target=windows)) = {
apple = { Fruit::Apple, "apple" }),
pear = {
Fruit::Pear, "pear"
},
},
_ignore(cfg(target=unix)) = {
banana = { Fruit::Banana, "banana" }),
},
)]
fn a_fruity_test(fruit: Fruit, name: &str) {
assert_eq!(fruit.name_of(), name)
}
Hi!
Avid user of test_case so its fun to see some competition. One feature I have always wanted from that lib is the ability to mark tests as ignored or inconclusive per test based on some flag (such as
cfg!(target=windows)
). Since you have a relatively simple syntax perhaps there is room to figure out nice ergonomics here