Crates.io | assay |
lib.rs | assay |
version | 0.1.1 |
source | src |
created_at | 2022-02-14 21:02:39.71515 |
updated_at | 2022-02-25 18:06:04.538552 |
description | A super powered testing macro for Rust |
homepage | |
repository | https://github.com/mgattozzi/assay |
max_upload_size | |
id | 532402 |
size | 37,808 |
as·say /ˈaˌsā,aˈsā/ noun - the testing of a metal or ore to determine its ingredients and quality.
Rust is great, but the testing leaves much to be desired sometimes. With custom
test frameworks being unstable and only an eRFC since 2018 there's not much we
can do to expand the abilities of our tests right? Well that's where assay
enters the picture. It seeks to solve a few problems when testing in rust:
cargo test -- --test-threads=1
or using some kind of mutex whereby you lose
the parallelization of running the test suitestd::env::set_working_dir
is prone to the above issuesasync
tests? There's no runtime and you have to do setup just to
run it.?
in your test means putting -> Result<(), Box<dyn std::error::Error>>
on every test and it can be tediousassert_eq
/assert_ne
output can be hard to grok and see why something is
equal/not equalassay
fixes these issues by:
cargo test
or if you use cargo nextest
then it let's that handle the processes
being in parallel in their own process for you. This means you can mutate per
process state as much as you want without affecting other tests and always
have your tests run in parallelchroot
without the jail aspect and no need for sudo
privileges)async
to the test functionResult<(), Box<dyn std::error::Error>>
. Use the ?
to your hearts content
and no need to add the Eye of Sauron (Ok(())
) to each testpretty_assertions
crate so that you can have
pretty output for assert_eq
and assert_ne
assay
was born out of personal frustration with the way things are and wanting
to handle the boilerplate without needing to write a whole test framework, while
also pushing the bounds of what we could have today on stable Rust.
While assay
is capable of a lot right now it's not without issues:
assay
,
because they run in another process. You should intentionally crash your test
to make sure it's actually working, because you'll have tests pass that really
shouldn't which frankly isn't greatcargo test
will
let you know where the issue actually isassay
fails.assay
does not work inside doc tests!assay
Take a look at HOW_TO_USE.md
(which is included in the crate
documentation) or tests/integration_tests.rs
.
We do not have a Minimum Supported Rust Version and only track stable
. Given
this crate uses 2021 edition rustc
>= 1.56 for now, but that's not always
guaranteed to be the case and later versions might require a greater version
than 1.56.
All files within this project are distributed under the Mozilla Public License
version 2.0. You can read the terms of the license in LICENSE.txt
.