proptest::test_runner

Struct TestRunner

Source
pub struct TestRunner { /* private fields */ }
Expand description

State used when running a proptest test.

Implementations§

Source§

impl TestRunner

Source

pub fn new(config: Config) -> Self

Create a fresh TestRunner with the given configuration.

The runner will use an RNG with a generated seed and the default algorithm.

In no_std environments, every TestRunner will use the same hard-coded seed. This seed is not contractually guaranteed and may be changed between releases without notice.

Source

pub fn deterministic() -> Self

Create a fresh TestRunner with the standard deterministic RNG.

This is sugar for the following:

let config = Config::default();
let algorithm = config.rng_algorithm;
TestRunner::new_with_rng(
    config,
    TestRng::deterministic_rng(algorithm));

Refer to TestRng::deterministic_rng() for more information on the properties of the RNG used here.

Source

pub fn new_with_rng(config: Config, rng: TestRng) -> Self

Create a fresh TestRunner with the given configuration and RNG.

Source

pub fn rng(&mut self) -> &mut TestRng

Returns the RNG for this test run.

Source

pub fn new_rng(&mut self) -> TestRng

Create a new, independent but deterministic RNG from the RNG in this runner.

Source

pub fn config(&self) -> &Config

Returns the configuration of this runner.

Source

pub fn bytes_used(&self) -> Vec<u8>

Dumps the bytes obtained from the RNG so far (only works if the RNG is set to Recorder).

§Panics

Panics if the RNG does not capture generated data.

Source

pub fn run<S: Strategy>( &mut self, strategy: &S, test: impl Fn(S::Value) -> TestCaseResult, ) -> Result<(), TestError<<S as Strategy>::Value>>

Run test cases against f, choosing inputs via strategy.

If any failure cases occur, try to find a minimal failure case and report that. If invoking f panics, the panic is turned into a TestCaseError::Fail.

If failure persistence is enabled, all persisted failing cases are tested first. If a later non-persisted case fails, its seed is persisted before returning failure.

Returns success or failure indicating why the test as a whole failed.

Source

pub fn run_one<V: ValueTree>( &mut self, case: V, test: impl Fn(V::Value) -> TestCaseResult, ) -> Result<bool, TestError<V::Value>>

Run one specific test case against this runner.

If the test fails, finds the minimal failing test case. If the test does not fail, returns whether it succeeded or was filtered out.

This does not honour the fork config, and will not be able to terminate the run if it runs for longer than timeout. However, if the test function returns but took longer than timeout, the test case will fail.

Source

pub fn reject_local(&mut self, whence: impl Into<Reason>) -> Result<(), Reason>

Update the state to account for a local rejection from whence, and return Ok if the caller should keep going or Err to abort.

Source

pub fn flat_map_regen(&self) -> bool

Increment the counter of flat map regenerations and return whether it is still under the configured limit.

Trait Implementations§

Source§

impl Clone for TestRunner

Source§

fn clone(&self) -> TestRunner

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TestRunner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TestRunner

Equivalent to: TestRunner::new(Config::default()).

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for TestRunner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 528 bytes