test-case
Provides #[test_case(...)] procedural macro attribute for generating parametrized test cases easily
3.3.1
59M downloads/mo
#1114 most downloaded on crates.io
frondeus/test-case
What this package is like to depend on
Last release 3 years ago
no release in 18 months
Release timing varies
gaps range from 9 days to 6 months
Nearly every release is documented
notes for 23 of 24 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
29 releases · first in 2019
0 releases in the last 12 months
see the full history below
Release timeline
29 releases · Sep 2019 to Nov 2023Releases
latest 29-
3.3.117 Nov 2023Release notes
Open source →What's Changed
- Avoid emitting unnecessary error messages by test cases & remove proc-macro2-diagnostics dependency by @dtolnay in #138
New Contributors
Full Changelog: v3.3.0...v3.3.1
Release notes
Open source →Fixes
- Avoid emitting additional misleading error messages by proc-macro2-diagnostics (#138)
-
3.3.017 Nov 2023Release notes
Open source →What's Changed
- Fix test_matrix example that does not compile in README by @ollien in #133
- Add the ability to have comments in matrix tests by @ollien in #132
- Remove proc-macro-error dependency by @tamird in #136
- .github: replace actions-rs with dtolnay/rust-toolchain, add caching by @tamird in #137
New Contributors
Full Changelog: v3.2.1...v3.3.0
Release notes
Open source →Features
- Allow comments in
test-matrixmacro (#132)
Improvements
- Drop
proc-macro-errordependency & improve error messages (#136)
-
3.2.117 Sep 2023Release notes
Open source →- Update
syndependency - Ensure that
test-casetargets latestcoreandmacrossubcrates.
Full Changelog: v3.2.0...v3.2.1
Release notes
Open source →Improvements
- Update
syndependency to 2.0 - Ensure that
test-caseselects correct version of it'scoreandmacrossubcrates
- Update
-
3.2.016 Sep 2023Release notes
Open source →What's Changed
- Retain allow attribute in test_case macro by @JohnPeel in #127
- Add test_matrix macro by @overhacked in #128
New Contributors
- @JohnPeel made their first contribution in #127
- @overhacked made their first contribution in #128
Full Changelog: v3.1.0...v3.2.0
Release notes
Open source →Features
- Add
test_matrixmacro: generates test cases from Cartesian product of possible test function argument values (#128)
Improvements
- Retain
allowattributes on test functions (#127)
-
3.1.002 Apr 2023Release notes
Open source →What's Changed
- Set MSRV in
Cargo.tomlto 1.58.1 by @samueltardieu in #116 - Set the span of test function Idents to the span of the origin attribute by @rpwachowski in #119
New Contributors
- @samueltardieu made their first contribution in #116
- @rpwachowski made their first contribution in #119
Full Changelog: v3.0.0...v3.1.0
Release notes
Open source →Features
- Copy attribute span to generated test functions so that IDEs recognize them properly as individual tests
Improvements
- Added LICENSE file to child crates
- Set MSRV in
-
3.0.013 Feb 2023Release notes
Open source →Overview
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 thetest_caseattribute.
Under the hood, all test cases that share the same body are grouped into a mod, giving clear and readable test results.Changes
- Split out
test-case-corecrate, allowing easier reuse in external crates. By @evforde
IMPORTANT
Starting with the 3.0 release, we are changing
test-caseMSRVpolicy. We no longer can maintain our goal of only bumpingMSRVwith 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 keepMSRVbreakage 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 uptest-case's maintenance processes and add more features in the coming months.Release notes
Open source →[IMPORTANT] Starting with 3.0 release we are changing
test-caseMSRV policy to support only 3 latest stable releases.Improvements
- Split out functional parts of
test-case-macroscrate intotest-case-corefor easy reuse by external libraries
- Split out
-
2.2.201 Oct 2022Release notes
Open source →What's Changed
- Use fully qualified #[test] attribute path by @alanbriolat in #105
New Contributors
- @alanbriolat made their first contribution in #105
Full Changelog: v2.2.1...v2.2.2
Release notes
Open source →Fixes
- Use fully qualified
testmacro path to avoid conflicts in workspace (#105)
-
2.2.121 Jul 2022Release notes
Open source →Bugfix release - ensure
test-casedepends on correct version oftest-case-macros
Full Changelog: v2.2.0...v2.2.1 -
2.2.021 Jul 2022 -
2.1.018 May 2022Release notes
Open source →What's Changed
- Refactoring: move test-case macro to separate subcrate by @luke-biel in #96
- Add 'len', 'count' and 'empty' complex assertions by @luke-biel in #97
- Add
match_regexto complex test-cases by @luke-biel in #98 - Allow keywords in void fn by @luke-biel in #100
Full Changelog: v2.0.2...v2.1.0
Release notes
Open source →Features
- Support
matches_regexcomplex test-case (requireswith-regexfeature) (#98) - Support
len,countandemptycomplex test-cases (#97)
Fixes
- Support keyword
ignoreon void fn (#100)
Improvements
- Move macros to separate subcrate so that test-case can export other things (#96)
-
2.0.225 Mar 2022Release notes
Open source →Fixes
- Covered missing cases in
matches X if Ytest_case variant (fixes the fact that previous bug fix didn't produce guard code)
- Covered missing cases in
-
2.0.121 Mar 2022Release notes
Open source →Fixes
matches Pattern if conditionparses correctly (if conditionpart wasn't allowed)
-
2.0.022 Feb 2022Release notes
Open source →Features
=> with |x: T| assert!(x)custom inline test assertions=> using path::to::fncustom fn test assertionsignore|inconclusivecan be combined with other keywords (eg.:=> ignore matches Ok(_))=> it|is ...syntax is a built-in (previously requiredhamcrest2crate integration)- Tested items are left in place where they were defined #77
- Simple test cases allow
Result<(), _>return types similar to native#[test]macro
Improvements
- Significant code refactoring
- Improved test case name selection
Breaking changes
- Deprecation of
inconclusivewithin test description string - it will no longer act like modifier keyword - Deprecation of
hamcrest2integration - Deprecation of
allow_resultfeature
-
2.0.0-rc313 Feb 2022 pre-releaseNothing published for this version
-
2.0.0-rc227 Jan 2022 pre-releaseNothing published for this version
-
2.0.0-rc119 Dec 2021 pre-releaseNothing published for this version
-
1.2.308 Feb 2022Release notes
Open source →Fixes
- Fix regression where
panicsandinconclusivewere not allowed ontest_casesreturning a value - Fix case where
test_casewould allow to return a type when only single attribute was used
- Fix regression where
-
1.2.206 Feb 2022Release notes
Open source →Fixes
test-caseno longer allows returning values from tested function without=>pattern (thanks to @tarka)- Behaviour can be reenabled via
allow_resultfeature
- Behaviour can be reenabled via
-
1.2.128 Oct 2021Release notes
Open source →Fixes
- Disabled clippy warning when test-case was generating
assert_eq(bool, bool)expression.
- Disabled clippy warning when test-case was generating
-
1.2.027 Jun 2021Release notes
Open source →Features
- Allow usage of fully qualified attribute
#[test_case::test_case](thanks to @tomprince)
Improvements
- Stopped code from emmiting unneded
()expression in test cases withexpectedfragment (thanks to @martinvonz)
- Allow usage of fully qualified attribute
-
1.1.010 Jan 2021Release notes
Open source →Features
- Added support for using
hamcrest2assertions with test case - Enabled support of
asyncvia tokio or similar - Enabled attribute passthrough for test cases - it means that you can combine
test-casewith other testing frameworks, given at least one#[test_case]attribute appears before mentioned framework in testing function
Deprecation
inconclusiveinside test case name will not be supported starting2.0.0
- Added support for using
-
1.0.112 Jan 2021Nothing published for this version
-
1.0.028 Jan 2020Release notes
Open source →Features
-
Added support for three new keywords:
panics,matchesandinconclusivewhich can be applied after=>token.matchesgives possibility to test patterns, like:#[test_case("foo" => matches Some(("foo", _)))]panicsgivesshould_panic(expected="...")for onetest_case:#[test_case(true => panics "Panic error message" ; "This should panic")] #[test_case(false => None ; "But this should return None")]inconclusiveignores 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 ())]
Major improvements
- Added extra unit tests - thanks to @luke-biel
- Replace
parented_test_casewith parsingtest_casedirectly from args - thanks to @luke-biel - Added keeping trailing underscores in names - thanks to @rzumer
Minor improvements
- Moved
lazy-staticdependency todev-dependencies - Fixed README - thanks to @luke-biel and @drwilco
Upgraded dependencies
- Upgraded
instato0.12.0
-
-
1.0.0-alpha-105 Nov 2019 pre-releaseNothing published for this version
-
0.3.301 Oct 2019 -
0.3.3-alpha101 Oct 2019 pre-releaseNothing published for this version
-
0.3.201 Oct 2019Release notes
Open source →Fixes
- Added support for
impl Trait- it worked in v2.x crate.
Minor improvements
- Added extra test cases
Upgraded dependencies
- Upgraded
version_checktov0.9.1
- Added support for
-
0.3.127 Sep 2019Release notes
Open source →Minor improvements:
- Refreshed readme
- Added CI for stable version of Rust. - thanks to @macisamuele
- Limited crate to Rust 1.29+ - thanks to @macisamuele
Upgraded dependencies:
- Upgraded
syn,quoteandproc-macro-2tov1 - Upgraded
lazy-staticto1.4.0 - Upgraded
instato0.11.0
-
0.3.027 Sep 2019Release notes
Open source →Breaking changes
-
Crate has new maintainer: Wojciech Polak :hand: :tada:
-
Crate has new name, as
test-case-derivehad no meaning forderivepart. -
Delimiter for test case description is
;instead of::.Reason:
::is valid part of expression and rustc treats const variable as path
New features
- Proper error propagation :tada:
When there is for example a typo in function body, rustc can now show location
of it instead of
test_caselocation. - Internally for tests crate uses
cargo instafor snapshot testing - Attribute is now compatible all other attributes like
#[should_panic]
-