Developers ask many questions about Assertables, Rust testing in general, macros in general, and more.
-
You can write better tests to improve reliability and maintainability.
-
You can handle more corner cases without needing to write custom code.
-
You can troubleshoot faster because error messages show specifics.
-
Easy to use: everything is well-documented with runnable examples.
-
More forms: for results, for solo/pair, for success return, etc.
-
Zero overhead: if you don't use a macro, then it's never compiled.
Because Assertables gives you more kinds of tests, stronger semantics, clearer naming, and better error messages.
Because Assertables has macro forms that do success returns, which enables you to do subsequent tests. This is especially helpful for asserts that use Result or Option, as well as for asserts that make external calls such as reading files or running commands.
Because Assertables has macro forms that do result returns, rather than panic. This enables production runtime uses such as for validations, verifications, resilience monitoring, chaos engineering, and more.
Suppose you want to assert that a text file has anything other than "TODO" Assertables:
assert_fs_read_to_string_ne!("example.txt", "TODO");Standard Rust:
assert!(fs::read_to_string("example.txt") == String::from("TODO"));Suppose you also want to assert the string length is at least 10.
Assertables:
let string = assert_fs_read_to_string_ne!("example.txt", "TODO");
assert_len_ge!(string, 10);Standard Rust:
let string = fs::read_to_string("alfa.txt");
assert!(string != String::from("TODO"));
assert!(string.len() >= 10);Suppose you also want to assert during production, without a panic, then trace the result.
Assertables:
let result = assert_fs_read_to_string_ne_as_result!("alfa.txt", "TODO");
trace!(result);Standard Rust:
let result = panic::catch_unwind(|| {
assert!(fs::read_to_string("alfa.txt") != String::from(""));
});
trace!(result);Because Assertables provides all the macros (and more) in all those crates (and more).
Because Assertables provides more specifics in the error messages, to help you troubleshoot.
Because Assertables provides the additional forms for success returns and result returns.
Yes, for some developers and organizations. Assertables provides more license choices than each of those crates.
Assertables provides Apache, MIT, GPL, BSD, and custom licenses for custom needs. See the LICENSE file for specifics.
Yes. There are assertion crates that provide even more functionality, especially for more-sophisticated needs.
-
The crate
static_assertionsprovides static code analysis, even before runningcargo test. -
The crate
assert_matchesprovides matching macros that have even more functionality than Assertables macrosassert_matchesandassert_not_matches. -
The crate
approxprovides floating point approximation macros that provide even more functionality than Assertables macrosassert_approx_eq,assert_in_delta,assert_in_epsilon, etc.
If you use GitHub, then you can create a GitHub issue, or create a GitHub pull request:
If you prefer email, then you can email the maintainer:
Constructive suggestions are always welcome.