32 · Testing
Independent cases from a test table
Add for (input, expected) in [...] after a literal test title. Each row is a separate runner case with its own body execution, label and filter identity. The row list must be a nonempty array literal so discovery does not execute user code.
On this page
Add for (input, expected) in [...] after a literal test title. Each row is a separate runner case with its own body execution, label and filter identity. The row list must be a nonempty array literal so discovery does not execute user code.
Complete example
Run this example with zolo test. Each row is an independent test case; ordinary Run does not execute test declarations.
Independent cases from a test table.
table_shipping.zolo
// Run with zolo test: each order total is an independent test case.
fn shipping(total: int) -> int {
if total >= 100 { 0 } else { 12 }
}
test "shipping at the free-delivery boundary" for (total, expected) in [
(0, 12),
(99, 12),
(100, 0),
(150, 0),
] {
assert_eq(shipping(total), expected)
}
Requires the Zolo CLI/host — open in the playground or run locally.
Reference
zolo test examples/features/table_shipping.zolo
See also