rust_test_framework
A data-driven testing framework for Rust.
Features
- Data-Driven Testing (DDT): Run the same test logic with multiple inputs.
- Test Fixtures: Support for
setupandteardownfunctions within a test module. - Procedural Macros: Easy-to-use attributes for defining test cases and fixtures.
- Clean Output: Clear results for individual test cases.
Usage
This project is currently in alpha.
Requirements
- Rust Version: 1.70.0 or higher
- Edition: 2021
Add this to your Cargo.toml:
[]
= "0.1.1-alpha.9"
Example usage:
Inlined Parameters
Use #[test_params] to provide test cases directly in your code. You can stack multiple attributes for multiple test cases.
use test_params;
Advanced Types and Rust-style Initialization
test_params supports idiomatic Rust syntax for structs, enums, Option, and Result.
use test_params;
use Deserialize;
External Data Sources
Use #[test_params_source] to load test cases from external files.
use ;
use Deserialize;
// This will generate a test case for each entry in `tests/data.json`
// if it's a list or inject it as a single entry if it's an object.
// You can also use multiple parameters with external sources.
// Each entry in the JSON array should then be an array of values.
Test Fixtures
Use #[test_fixture] on a module to enable #[setup] and #[teardown] functions.
use ;
License
Licensed under the Apache License, Version 2.0.