🔬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::black_box;
Experimentalpub use self::bench::Bencher;
Experimentalpub use self::types::TestName::*;
Experimentalpub use NamePadding::*;
Experimentalpub use TestFn::*;
Experimentalpub use TestName::*;
Experimentalpub use self::ColorConfig::*;
Experimental
Modules§
Structs§
- OptionsExperimentalOptions 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.
- TestDescExperimental
- TestDescAndFnExperimental
- TestIdExperimental
- TestOptsExperimental
Enums§
- ColorConfigExperimentalWhether should console output be colored or not
- NamePaddingExperimental
- OutputFormatExperimentalFormat of the test results output
- RunIgnoredExperimentalWhether ignored test should be run or not
- ShouldPanicExperimentalWhether test is expected to panic or not
- TestFnExperimental
- TestNameExperimental
- TestTypeExperimentalType of the test according to the rust book conventions.
Functions§
- assert_test_resultExperimentalInvoked when unit tests terminate. Returns
Result::Err
if the test is considered a failure. By default, invokesreport()
and checks for a0
result. - convert_benchmarks_to_testsExperimental
- filter_testsExperimental
- run_testExperimental
- run_testsExperimental
- run_tests_consoleExperimentalA simple console test runner. Runs provided tests reporting process and results to the stdout.
- test_mainExperimental
- test_main_staticExperimentalA variant optimized for invocation with a static test vector. This will panic (intentionally) when fed any dynamic tests.
- test_main_static_abortExperimentalA variant optimized for invocation with a static test vector. This will panic (intentionally) when fed any dynamic tests.