Crates.io | multiplatform_test |
lib.rs | multiplatform_test |
version | 0.3.0 |
source | src |
created_at | 2023-04-24 20:38:53.933576 |
updated_at | 2024-11-08 19:26:24.054035 |
description | A simple attribute macro to combine `#[test]` and `#[wasm_bindgen_test]` |
homepage | |
repository | |
max_upload_size | |
id | 847891 |
size | 19,239 |
multiplatform_test
Provides a proc-macro that expands to testing on platforms relevant to
Hydroflow. By default, expands to testing on the host (using the normal
#[test]
attribute) and wasm (using #[wasm_bindgen_test]
).
For example, the test
use multiplatform_test::multiplatform_test;
#[multiplatform_test]
fn my_test() {
// ...
}
Expands to
#[test]
#[wasm_bindgen_test::wasm_bindgen_test]
fn my_test() {
// ...
}
[dependencies]
multiplatform_test = * # replace with version.
If you're using wasm
naturally you will need to add the wasm_bindgen_test
crate as a dependency.
There are many platforms which can be specified:
test
- Adds a standard #[test]
attribute.tokio
- Adds a #[tokio::test]
attribute.async_std
- Adds an #[async_std::test]
attribute.hydroflow
- Adds a #[hydroflow::test]
attribute.wasm
- Adds a #[wasm_bindgen_test::wasm_bindgen_test]
attribute.env_logging
- Registers env_logger
for log
ging.env_tracing
- Registers a FmtSubscriber
with an EnvFilter
for tracing
.You can test on a subset of platforms by passing in the platforms in parens:
use multiplatform_test::multiplatform_test;
#[multiplatform_test(test, env_logging)] // Only test on the standard `#[test]` platform, but enables logging
fn my_test() {
// ...
}
expands to
use multiplatform_test::multiplatform_test;
#[test]
fn my_test() {
let _ = env_logger::builder().is_test(true).try_init();
// ...
}