#[adtest]
Expand description
Macro that derives test for function, this macro allows you to have setup and cleanup function for your tests.
Usage:
#[adtest::adtest(
setup = setup_function,
cleanup = cleanup_function
)]
fn very_complex_test() {
println!("I am regular test")
}
If you need async in your test add tokio
to your crate and just add adtest
macro
on async function
#[adtest::adtest]
#[adtest::adtest(
setup = setup_function,
cleanup = cleanup_function
)]
async fn very_complex_test() {
println!("I am very complex async test");
}
There are currently two possible attributes on adtest
on is setup
other is cleanup
.
Use setup
attribute to pass function that runs code that is needed for test, example is mocking entities in db,
creating file, etc.
Use cleanup
function to cleanup after test or setup
for example to remove files or entities generated by test.
If your setup or cleanup function is async
then you must specify it with async
#[adtest::adtest(
setup = async setup_function,
cleanup = async cleanup_function
)]
fn very_complex_test() {
println!("I am regular test")
}