NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io
crates.io, #1189 most downloaded on crates.io
Provides #[test_case(...)] procedural macro attribute for generating parametrized test cases easily
Latest stable
3.4.1
Last release 20 days ago
01 Nov 2026
Ships unpredictably
gaps range from 2 weeks to 2.9 years
Nearly every release is documented
notes for 26 of 26 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
31 releases · first in 2019
Drag across the ruler to compare, or tap a release to open it.
test_case no longer triggers clippy::redundant_test_prefix lint
Adds test case number to automatically distinguish test cases with the same generated name ( #151 ) Instead of having a conflict in example like this:
#[test_case(42)]
#[test_case("42")]
fn cases_are_enumerated(value: impl std::fmt::Display) {
assert_eq!("42", &value.to_string())
}It now generates prefix name for each test case. In all cases:
test cases_are_enumerated::test_case_1_42_expects ... ok
test cases_are_enumerated::test_case_2_42_expects ... ok
assert_eq!(result, expectation) instead of previous assert_eq!(expectation, result);Your coding agent can read these notes before it upgrades. Set up the MCP server →
Avoid emitting unnecessary error messages by test cases & remove proc-macro2-diagnostics dependency by @dtolnay in https://github.com/frondeus/test-ca
Full Changelog: https://github.com/frondeus/test-case/compare/v3.3.0...v3.3.1
Full Changelog: v3.3.0...v3.3.1
Fix test_matrix example that does not compile in README by @ollien in https://github.com/frondeus/test-case/pull/133
Full Changelog: https://github.com/frondeus/test-case/compare/v3.2.1...v3.3.0
Full Changelog: v3.2.1...v3.3.0
test-matrix macro (#132)proc-macro-error dependency & improve error messages (#136)Ensure that test-case targets latest core and macros subcrates.
syn dependencytest-case targets latest core and macros subcrates.Full Changelog: v3.2.0...v3.2.1
syn dependency to 2.0test-case selects correct version of it's core and macros subcratesRetain allow attribute in test_case macro by @JohnPeel in https://github.com/frondeus/test-case/pull/127
Full Changelog: https://github.com/frondeus/test-case/compare/v3.1.0...v3.2.0
Full Changelog: v3.1.0...v3.2.0
test_matrix macro: generates test cases from Cartesian product of possible test function argument values (#128)allow attributes on test functions (#127)Set MSRV in Cargo.toml to 1.58.1 by @samueltardieu in https://github.com/frondeus/test-case/pull/116
Cargo.toml to 1.58.1 by @samueltardieu in https://github.com/frondeus/test-case/pull/116Full Changelog: https://github.com/frondeus/test-case/compare/v3.0.0...v3.1.0
Cargo.toml to 1.58.1 by @samueltardieu in #116Full Changelog: v3.0.0...v3.1.0
This crate provides the #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input paramet
This crate provides the #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in the test_case attribute.
Under the hood, all test cases that share the same body are grouped into a mod, giving clear and readable test results.
test-case-core crate, allowing easier reuse in external crates. By @evfordeStarting with the 3.0 release, we are changing test-case MSRV policy. We no longer can maintain our goal of only bumping MSRV with major SemVer releases partly due to how fast rust landscape changes and partly to how the rest of the rust ecosystem prefers instead not to keep MSRV breakage treated as SemVer breakage, making stricter policies hard to maintain with limited resources we have. The current goal is to support up to 3 of the latest stable releases.
We hope that with this change, we'll be able to speed up test-case's maintenance processes and add more features in the coming months.
[IMPORTANT] Starting with 3.0 release we are changing test-case MSRV policy to support only 3 latest stable releases.
test-case-macros crate into test-case-core for easy reuse by external librariesUse fully qualified #[test] attribute path by @alanbriolat in https://github.com/frondeus/test-case/pull/105
Full Changelog: https://github.com/frondeus/test-case/compare/v2.2.1...v2.2.2
Full Changelog: v2.2.1...v2.2.2
test macro path to avoid conflicts in workspace (#105)Bugfix release - ensure test-case depends on correct version of test-case-macros Full Changelog: https://github.com/frondeus/test-case/compare/v2.2.0.
Bugfix release - ensure test-case depends on correct version of test-case-macros
Full Changelog: https://github.com/frondeus/test-case/compare/v2.2.0...v2.2.1
Bugfix release - ensure test-case depends on correct version of test-case-macros
Full Changelog: v2.2.0...v2.2.1
Allow ignore reason by @ijc in https://github.com/frondeus/test-case/pull/103
Full Changelog: https://github.com/frondeus/test-case/compare/v2.1.0...v2.2.0
Refactoring: move test-case macro to separate subcrate by @luke-biel in https://github.com/frondeus/test-case/pull/96
match_regex to complex test-cases by @luke-biel in https://github.com/frondeus/test-case/pull/98Full Changelog: https://github.com/frondeus/test-case/compare/v2.0.2...v2.1.0
match_regex to complex test-cases by @luke-biel in #98Full Changelog: v2.0.2...v2.1.0
matches_regex complex test-case (requires with-regex feature) (#98)len, count and empty complex test-cases (#97)ignore on void fn (#100)Fixed the fact that match X if Y didn't produce correct guard code which resulted in false positives.
match X if Y didn't produce correct guard code which resulted in false positives.Full Changelog: https://github.com/frondeus/test-case/compare/v2.0.1...v2.0.2
matches X if Y test_case variant (fixes the fact that previous bug fix didn't produce guard code)matches Pattern if condition parses correctly (if condition part wasn't allowed despite being documented)
matches Pattern if condition parses correctly (if condition part wasn't allowed despite being documented)Full Changelog: https://github.com/frondeus/test-case/compare/v2.0.0...v2.0.1
Deprecation of inconclusive within test description string - it will no longer act like modifier keyword
This crate provides the #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in the test_case attribute.
Under the hood, all test cases that share the same body are grouped into a mod, giving clear and readable test results.
=> with |x: T| assert!(x) custom inline test assertions=> using path::to::fn custom fn test assertionsignore and inconclusive can be combined with other keywords=> it|is ... syntax is a built-in (previously required hamcrest2 crate integration)Result<(), _> as #[test] attribute does #50inconclusive within test description string - it will no longer act like modifier keywordhamcrest2 integration (it and is are kept, complex assertions now have different syntax)Now it is possible to pass the closure which will assert the test case.
#[test_case(1.0 => with |v: f64| assert!(v.is_infinite()))]
#[test_case(0.0 => with |v: f64| assert!(v.is_nan()))]
fn divide_by_zero_f64_with_lambda(input: f64) -> f64 {
input / 0.0f64
}
Not only the closure is possible but also you can point to the plain function:
Given:
fn assert_is_power_of_two(input: u64) {
assert!(input.is_power_of_two())
}
You can now assert:
#[test_case(1 => using assert_is_power_of_two)]
fn power_of_two_with_using(input: u64) -> u64 {
input
}
Not only that, you can also create a higher order function like this one:
fn wrapped_pretty_assert(expected: u64) -> impl Fn(u64) {
move |actual: u64| { pretty_assertions::assert_eq!(actual, expected) }
}
to achieve even better parameterized tests:
#[test_case(1 => using wrapped_pretty_assert(1))]
fn pretty_assertions_usage(input: u64) -> u64 {
input
}
ignore and inconclusive can be combined with other keywordsSometimes you might want to temporarily disable one of the test cases without removing the testing assertion.
Thanks to this release now it is possible:
#[test_case(12 => ignore matches Ok(_))]
fn ignore_supported(_value: u64) -> Result<(), Box<dyn Error>> {
todo!()
}
=> it|is ... syntax is a built-inPreviously test-case was integrated with hamcrest2 assertion crate.
This release breaks this dependency and provides an alternative solution:
#[test_case(1.0 => is equal_to 2.0 ; "eq1")]
#[test_case(1.0 => is greater_or_equal_than 1.0 ; "geq1")]
#[test_case(1.0 => is geq 1.0 ; "geq2")]
#[test_case(1.0 => is almost_equal_to 2.1 precision 0.15 ; "almost_eq1")]
#[test_case(1.0 => is almost 2.0 precision 0.01 ; "almost_eq2")]
fn complex_tests(input: f64) -> f64 {
input * 2.0
}
It also supports asserting paths:
#[test_case("Cargo.toml" => is existing_path)]
#[test_case("src/lib.rs" => is file)]
#[test_case("src/" => is dir ; "short_dir")]
#[test_case("src/" => is directory ; "long_dir")]
fn create_path(val: &str) -> std::path::PathBuf {
std::path::PathBuf::from(val)
}
As well as collections:
#[test_case(vec![1, 2, 3, 4] => it contains 1)]
#[test_case(vec![1, 2, 3, 4] => it contains_in_order [3, 4])]
fn contains_tests(items: Vec<u64>) -> Vec<u64> {
items
}
You can also use the combinators:
#[test_case(1.0 => is gt 0.0 and lt 5.0)]
#[test_case(0.3 => is (gt 0.0 and lt 1.0) or gt 1.2)]
#[test_case(0.7 => is (gt 0.0 and lt 1.0) or gt 1.2)]
fn combinators(v: f32) -> f32 {
v * 2.0
}
Note: The combinators are still a bit unpolished. Currently
test_caseonly supports one type of combinator per group. It means that if you want to combineandwithoryou need to use()to explicitly mark the precedence. However... We hope that in the next version we will lift this restriction by providing a full precedence parsing.
Result<(), _>Finally, the test_case macro now supports the Result return type just like the #[test] attribute does.
It means the test case would fail if the function returns Err(...).
#[test_case(12)]
#[test_case(13)]
fn is_even(value: u64) -> Result<(), String> {
if value % 2 == 0 {
Ok(())
} else {
Err("is odd".to_string())
}
}
=> with |x: T| assert!(x) custom inline test assertions=> using path::to::fn custom fn test assertionsignore|inconclusive can be combined with other keywords (eg.: => ignore matches Ok(_))=> it|is ... syntax is a built-in (previously required hamcrest2 crate integration)Result<(), _> return types similar to native #[test] macroinconclusive within test description string - it will no longer act like modifier keywordhamcrest2 integrationallow_result featuresimple test cases support returning Result<_, _> as #[test] macro does #50
Result<_, _> as #[test] macro does #50complex test_case supports now not, and and or logical combinators
complex test_case supports now not, and and or logical combinatorsDeprecation of inconclusive within test description string - it will no longer act like modifier keyword
=> with |x: T| assert!(x) custom inline test assertions=> using path::to::fn custom fn test assertionsignore and inconclusive can be combined with other keywords (eg.: => ignore matches Ok(_))inconclusive within test description string - it will no longer act like modifier keywordhamcrest2 integration (it and is are kept, complex assertions now have different syntax)Fix regression where panics and inconclusive were not allowed on test_cases returning a value
panics and inconclusive were not allowed on test_cases returning a valuetest_case would allow to return a type when only single attribute was usedtest-case no longer allows returning values from tested function without => pattern #50 (thanks to @tarka)
test-case no longer allows returning values from tested function without => pattern #50 (thanks to @tarka)
test-case no longer allows returning values from tested function without => pattern (thanks to @tarka)
allow_result featureDisabled clippy warning when test-case was generating assert_eq!(bool, bool) expression.
assert_eq!(bool, bool) expression.Allow usage of fully qualified attribute #[test_case::test_case] (thanks to @tomprince)
#[test_case::test_case] (thanks to @tomprince)() expression in test cases with expected fragment (thanks to @martinvonz)Added support for using hamcrest2 assertions with test case
hamcrest2 assertions with test caseasync via tokio or similartest-case with other testing frameworks,
given at least one #[test_case] attribute appears before mentioned framework in testing functioninconclusive inside test case name will not be supported starting 2.0.0Legacy release supporting MSRV < 1.39, including syn::export fix
Legacy release supporting MSRV < 1.39, including syn::export fix
This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in test_case attribute.
Under the hood, all test cases that share same body are grouped into mod, giving clear and readable test results.
Added support for three new keywords: panics, matches and inconclusive which can be applied after => token.
matches gives possibility to test patterns, like:
#[test_case("foo" => matches Some(("foo", _)))]
panics gives should_panic(expected="...") for one test_case:
#[test_case(true => panics "Panic error message" ; "This should panic")]
#[test_case(false => None ; "But this should return None")]
inconclusive ignores one specific test case.- thanks to @luke-biel
#[test_case("42")]
#[test_case("XX" ; "inconclusive - parsing letters temporarily doesn't work, but it's ok")]
#[test_case("na" => inconclusive ())]
parented_test_case with parsing test_case directly from args - thanks to @luke-biellazy-static dependency to dev-dependenciesinsta to 0.12.0Nothing published for this version
Fixed "inconclusive" feature with different cases. ```rust
#[test_case(1 ; "this test is inconclusive and will always be")]
#[test_case(2 ; "this test is also Inconclusive")]
#[test_case(3 ; "this test is also INCONCLUSIVE even uppercase")]
#[test_case(4 ; "this test is also iNCONCLUSIVE even inverted caps")]
Nothing published for this version
This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in test_case attribute.
Under the hood, all test cases that share same body are grouped into mod, giving clear and readable test results.
impl Trait - it worked in 2.x crate.version_check to v0.9.1impl Trait - it worked in v2.x crate.version_check to v0.9.1This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
This crate provides #[test_case] procedural macro attribute that generates multiple parametrized tests using one body with different input parameters.
A test is generated for each data set passed in test_case attribute.
Under the hood, all test cases that share same body are grouped into mod, giving clear and readable test results.
test-case-derive had no meaning for derive part.; instead of ::.Reason: :: is valid part of expression and rustc treats const variable as path
cargo insta for snapshot testing#[should_panic], however these attributes will be applied on every test caseCrate has new maintainer: Wojciech Polak :hand: :tada:
Crate has new maintainer: Wojciech Polak :hand: :tada:
Crate has new name, as test-case-derive had no meaning for derive part.
Delimiter for test case description is ; instead of ::.
Reason: :: is valid part of expression and rustc treats const variable as path
test_case location.cargo insta for snapshot testing#[should_panic]One column per quarter.