Expand description
§Easy Desktop Test
The crate streamlines the use of rstest
with support for tracing
(using test-log
). async
tests are supported using the tokio
framework.
The crate re-exports the assertions from static-assertions
, and the #[serial]
attribute of serial_test
for pure convenience.
§Usage
Unfortunately, due to the nature of macros, besides this crate the user still needs a few dev-dependencies:
cargo.toml:
[dev-dependencies]
edtest = ...
rstest = ...
test-log = ...
# Only needed if using the #[serial] attribute to make tests not run concurrently
serial_test = ...
tests:
use edtest::test;
use tracing::*;
/// Normal synchronous test.
/// Note that `cargo test` still tries to run these concurrently!
#[test]
fn sync_test() {
info!("Tracing output is captured and part of the test output");
}
/// Async tests using `tokio` are fully supported - they can even
/// be run using `serial` (non-concurrent)
#[test]
#[edtest::serial]
async fn async_value_test(
#[values(0, 1, 2, 3, 4, 5)] a: u32,
#[values(0, 1, 2, 3, 4, 5)] b: u32,
) {
use edtest::assert_cfg;
// `static_assertions` are re-exported for convenience
assert_cfg!(test);
trace!(a, b);
let ab = super::add(a, b);
let ba = b + a;
assert_eq!(ab, ba);
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
}
§Noteworthy crates
§General
§Messing with files
§Network
§CLI programs
assert_cmd
Simplify integration testing of CLI’srexpect
Running/testing interactive CLI’s
§Tools
- coverage LLVM Coverage reports the easy way
Modules§
- _core
- The Rust Core Library
Macros§
- assert_
cfg - Asserts that a given configuration is set.
- assert_
eq_ align - Asserts that types are equal in alignment.
- assert_
eq_ size - Asserts that types are equal in size.
- assert_
eq_ size_ ptr - Asserts that values pointed to are equal in size.
- assert_
eq_ size_ val - Asserts that values are equal in size.
- assert_
fields - Asserts that the type has the given fields.
- assert_
impl_ all - Asserts that the type implements all of the given traits.
- assert_
impl_ any - Asserts that the type implements any of the given traits.
- assert_
impl_ one - Asserts that the type implements exactly one in a set of traits.
- assert_
not_ impl_ all - Asserts that the type does not implement all of the given traits.
- assert_
not_ impl_ any - Asserts that the type does not implement any of the given traits.
- assert_
obj_ safe - Asserts that the traits support dynamic dispatch (object-safety).
- assert_
trait_ sub_ all - Asserts that the trait is a child of all of the other traits.
- assert_
trait_ super_ all - Asserts that the trait is a parent of all of the other traits.
- assert_
type_ eq_ all - Asserts that all types in a list are equal to each other.
- assert_
type_ ne_ all - Asserts that all types are not equal to each other.
- const_
assert - Asserts that constant expressions evaluate to
true
. - const_
assert_ eq - Asserts that constants are equal in value.
- const_
assert_ ne - Asserts that constants are not equal in value.
Attribute Macros§
- fixture
- Creation of test-fixtures. see the fixture documentation.
- serial
- Allows for the creation of serialised Rust tests
- test
- Generate a test function using
rstest
. If used on aasync
function the test will use thetokio
runtime. See the rstest documentation.