🔬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
- benchExperimentalBenchmarking module.
- Module converting command-line arguments into test configuration.
- Module providing interface for running tests in the console.
- Module containing different events that can occur during tests execution process.
- Module with common helpers not directly related to tests but used in
libtest
. - Enums denoting options for test execution.
- statsExperimental
- Terminal formatting module.
- testExperimental
- Module
time
contains everything related to the time measurement of unit tests execution. The purposes of this module: - Common types used by
libtest
.
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.
Constants
Functions
- Fixed frame used to clean the backtrace with
RUST_BACKTRACE=1
. - 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
- Clones static values for putting into a dynamic vector, which test_main() needs to hand out ownership of tests to parallel test runners.
- 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.