Skip to content

Commit

Permalink
feat: Add support for custom test attributes
Browse files Browse the repository at this point in the history
You may now add the attribute #[parameterized_macro(...)] after a #[parameterized(...)] attribute. The ... in the parameterized_macro may be replaced with a custom test attribute such as tokio::test.

As an additional treat (because the above would not half be as useful without some of these), the parameterized test function now also parses and provides codegen for the async, const and unsafe keywords, in addition to the also newly added support for specifying return types.
  • Loading branch information
foresterre committed Mar 5, 2024
1 parent 866805b commit e018621
Show file tree
Hide file tree
Showing 27 changed files with 420 additions and 272 deletions.
40 changes: 11 additions & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,18 @@ This is the changelog for [parameterized](https://github.com/foresterre/paramete
which provides an attribute macro, to be used for parameterized testing.

If you found an issue, have a suggestion or want to provide feedback or insights, please feel free to open an issue on
the [issue tracker](https://github.com/foresterre/parameterized/issues), or open a topic in the [discussions section](https://github.com/foresterre/parameterized/discussions).
the [issue tracker](https://github.com/foresterre/parameterized/issues), or open a topic in
the [discussions section](https://github.com/foresterre/parameterized/discussions).

## [1.1.0] - 2023-10-13
## [2.0.0] - 2024-03-05

### Added
# Added

* `parameterized-macro` now supports test signatures with any return type supported by the test macro, not just the unit type
* Added support for custom test macros (e.g., `#[tokio::test]` instead of the default `#[test]`) by specifying the
`#[parameterized_macro(...)]` attribute.

**Example**

```rust
use parameterized::parameterized;

#[parameterized(v = { Ok(1), Err("Oh noes".to_string()) })]
fn my_test(v: Result<u32, String>) -> Result<(), String> {
let value = v?; // Can use the question mark operator here, since return type is Result, which implements the Termination trait

assert_eq!(value, 1);

Ok(())
}
```

### Changed

* Updated MSRV to Rust `1.56`
* Updated parameterized-macro to `1.1.0`

[1.1.0]: https://github.com/foresterre/parameterized/releases/tag/v1.1.0
* `#[parameterized]` macro now parses and regenerates optional `const`, `async`, `unsafe` and return type items for `fn`
definitions.

## [1.0.1] - 2022-11-09

Expand All @@ -55,17 +38,16 @@ fn my_test(v: Result<u32, String>) -> Result<(), String> {

### Fixed

* Fix issue where parameterized-macro used the public API of the syn::export module which the docs described as
a non-public implementation details module, not covered by semver

* Fix issue where parameterized-macro used the public API of the syn::export module which the docs described as
a non-public implementation details module, not covered by semver

[0.3.1]: https://github.com/foresterre/parameterized/releases/tag/v0.3.1

## [0.3.0] - 2020-12-30

This release consists of internal changes. There are no changes for users.
An alternative syntax which was added after 0.2.0, but was never released,
has been moved into its own project named [Yare](https://github.com/foresterre/yare).
has been moved into its own project named [Yare](https://github.com/foresterre/yare).

[0.3.0]: https://github.com/foresterre/parameterized/releases/tag/v0.3.0

Expand Down
91 changes: 39 additions & 52 deletions Cargo.lock.msrv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
[package]
name = "parameterized"
version = "1.1.0"
version = "1.0.1"
authors = ["Martijn Gribnau <garm@ilumeo.com>"]
edition = "2021"
edition = "2018"
license = "MIT OR Apache-2.0"
description = "Procedural macro which brings a compact parameterized testing implementation to Rust (inspired by JUnit @ParameterizedTest)"
documentation = "https://docs.rs/crate/parameterized"
repository = "https://github.com/foresterre/parameterized"
readme = "README.md"
keywords = ["parameterized", "parametrized", "test", "unit-test", "junit"]
categories = ["development-tools", "development-tools::testing"]
rust-version = "1.56"

[package.metadata]
msrv = "1.56.0"

[dependencies]
parameterized-macro = { path = "parameterized-macro", version = "1" }
[features]
# not semver protected
square-brackets-old-error-message = ["parameterized-macro/square-brackets-old-error-message"]

[workspace]
members = ["parameterized-macro"]

[features]
# not semver protected
square-brackets-old-error-message = ["parameterized-macro/square-brackets-old-error-message"]
[dependencies]
parameterized-macro = { path = "parameterized-macro", version = "1" }

[dev-dependencies]
tokio = { version = "1", features = ["full"] }
Loading

0 comments on commit e018621

Please sign in to comment.