Attribute Macro tests_bin::unit_tests
source · #[unit_tests]
Expand description
Link a unit tests module with an item.
Syntax
#[unit_tests("relative_path.rs" {, "module name"})] item
The element in {}
are optional. The extension .rs
is required.
Path
By default, the macro will look in {project_folder}/tests/unit/
for unit tests file.
This can be changed here
Example(s)
use tests_bin::unit_tests;
// Will link a module to `tests/unit/add.rs`
// with a module named `pub_fn_add_usize`.
#[unit_tests("add.rs")]
pub fn add(left: usize, right: usize) -> usize {
left + right
}
// Will link a module to `tests/unit/operation/multiply.rs`
// with a module named `my_multiply_operation`.
#[unit_tests("operation/multiply.rs", "my_multiply_operation")]
pub fn multiply(left: usize, right: usize) -> usize {
left * right
}