🔬This is a nightly-only experimental API. (
test
)Expand description
Support code for rustc’s built in unit-test and micro-benchmarking framework.
Almost all user code will only be interested in Bencher
and
black_box
. All other interactions (such as writing tests and
benchmarks themselves) should be done via the #[test]
and
#[bench]
attributes.
See the Testing Chapter of the book for more details.
Re-exports§
pub use self::bench::Bencher;
Experimental pub use self::bench::black_box;
Experimental pub use self::ColorConfig::*;
Experimental pub use self::types::TestName::*;
Experimental pub use NamePadding::*;
Experimental pub use TestFn::*;
Experimental pub use TestName::*;
Experimental
Modules§
Structs§
- Options
Experimental Options for the test run defined by the caller (instead of CLI arguments). In case we want to add other options as well, just add them in this struct. - Test
Desc Experimental - Test
Desc AndFn Experimental - TestId
Experimental - Test
Opts Experimental
Enums§
- Color
Config Experimental Whether should console output be colored or not - Name
Padding Experimental - Output
Format Experimental Format of the test results output - RunIgnored
Experimental Whether ignored test should be run or not - Should
Panic Experimental Whether test is expected to panic or not - TestFn
Experimental - Test
Name Experimental - Test
Type Experimental Type of the test according to the Rust book conventions.
Functions§
- assert_
test_ result Experimental Invoked when unit tests terminate. ReturnsResult::Err
if the test is considered a failure. By default, invokesreport()
and checks for a0
result. - convert_
benchmarks_ to_ tests Experimental - filter_
tests Experimental - run_
test Experimental - run_
tests Experimental - run_
tests_ console Experimental A simple console test runner. Runs provided tests reporting process and results to the stdout. - test_
main Experimental - test_
main_ static Experimental A variant optimized for invocation with a static test vector. This will panic (intentionally) when fed any dynamic tests. - test_
main_ static_ abort Experimental A variant optimized for invocation with a static test vector. This will panic (intentionally) when fed any dynamic tests.