tanu-derive
Procedural macros for the tanu WebAPI testing framework.
Overview
tanu-derive provides the essential procedural macros that power the tanu testing framework:
#[tanu::test]- Transforms functions into discoverable test cases#[tanu::main]- Generates the main function for test execution
These macros enable compile-time test discovery and registration, allowing the tanu framework to automatically find and execute your tests without runtime reflection.
Key Features
Test Discovery
The #[tanu::test] macro automatically registers test functions with the tanu test runner:
async
Parameterized Tests
Support for parameterized tests with multiple parameter sets:
async
Main Function Generation
The #[tanu::main] macro generates the appropriate main function:
async
Usage
Add tanu-derive to your Cargo.toml:
[]
= "0.10.0"
However, tanu-derive is typically used through the main tanu crate, which re-exports these macros:
[]
= "0.10.0"
Macro Details
#[tanu::test]
The test macro supports several patterns:
Basic Test:
async
Parameterized Test:
async
Multiple Parameters:
async
#[tanu::main]
The main macro generates the entry point for your test suite:
use ;
async
Test Function Requirements
Functions annotated with #[tanu::test] must:
- Be
asyncfunctions - Return a
Resulttype (typicallyeyre::Result<()>) - Take parameters matching the macro arguments (for parameterized tests)
Error Handling
The macro system integrates seamlessly with Rust's error handling:
async
Compilation
The macros perform compile-time code generation, creating a test registry that can be efficiently queried at runtime. This approach eliminates the need for runtime reflection while maintaining full type safety.
Integration
tanu-derive is designed to work seamlessly with:
tanu-corefor HTTP client and assertionstanu-tuifor interactive test execution- Standard Rust async ecosystem (tokio, futures, etc.)
For complete examples and documentation, see the main tanu repository.