Forwarding input arguments of #[tokio::test] annotated tests · Issue #2388 · tokio-rs/tokio (original) (raw)
Test fixture libraries such as rstest tend to use a proc macro to inject fixtures in tests, based on function parameters of the test function. Example:
#[fixture] fn fix -> u32 {2} #[rstest] fn foo(fix: u32) { assert_eq!(2, fix) }
Currently, there is an ongoing discussion in rstest on how to best integrate with test-suites other than the default Rust #[test]
, in particular those that use async
, such as #[tokio::test]
.
In order to transparently integrate and make the #[rstest]
and #[tokio::test]
attributes "commutative", the function arguments of a test should simply be forwarded by the tokio::test
proc macro. Currently, adding function arguments to a test triggers a custom error. As far as I know, Rust itself would generate an error like that, even without that part of code.
This brings me to my main question: dropping that check would allow tighter cooperation with rstest
, and I believe with other, future fixture frameworks too. Would Tokio accept a patch, dropping that check, like the one actix-net just accepted? As far as I can tell, everything else is already in place.