Struct TestRunner
pub struct TestRunner { /* private fields */ }
State used when running a proptest test.
Implementations
impl TestRunner
fn new(config: Config) -> SelfCreate a fresh
TestRunnerwith the given configuration.The runner will use an RNG with a generated seed and the default algorithm.
In
no_stdenvironments, everyTestRunnerwill use the same hard-coded seed. This seed is not contractually guaranteed and may be changed between releases without notice.fn deterministic() -> SelfCreate a fresh
TestRunnerwith the standard deterministic RNG.This is sugar for the following:
# use *; let config = default; let algorithm = config.rng_algorithm; new_with_rng;Refer to
TestRng::deterministic_rng()for more information on the properties of the RNG used here.fn new_with_rng(config: Config, rng: TestRng) -> SelfCreate a fresh
TestRunnerwith the given configuration and RNG.fn rng(&mut self) -> &mut TestRngReturns the RNG for this test run.
fn new_rng(&mut self) -> TestRngCreate a new, independent but deterministic RNG from the RNG in this runner.
fn config(&self) -> &ConfigReturns the configuration of this runner.
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.
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 viastrategy.If any failure cases occur, try to find a minimal failure case and report that. If invoking
fpanics, the panic is turned into aTestCaseError::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.
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
forkconfig, and will not be able to terminate the run if it runs for longer thantimeout. However, if the test function returns but took longer thantimeout, the test case will fail.fn reject_local(&mut self, whence: impl Into<Reason>) -> Result<(), Reason>Update the state to account for a local rejection from
whence, and returnOkif the caller should keep going orErrto abort.fn flat_map_regen(&self) -> boolIncrement the counter of flat map regenerations and return whether it is still under the configured limit.
Trait Implementations
impl Clone for TestRunner
fn clone(&self) -> TestRunner
impl Debug for TestRunner
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Default for TestRunner
fn default() -> Self
impl Display for TestRunner
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl !RefUnwindSafe for TestRunner
impl !UnwindSafe for TestRunner
impl Freeze for TestRunner
impl Send for TestRunner
impl Sync for TestRunner
impl Unpin for TestRunner
impl UnsafeUnpin for TestRunner
Blanket Implementations
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for TestRunner
where
ST: ?Sized,
DT: ?Sized,
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for TestRunner
where
ST: ?Sized,
DT: ?Sized,
impl<T> Any for TestRunner
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for TestRunner
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for TestRunner
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for TestRunner
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for TestRunner
fn from(t: T) -> TReturns the argument unchanged.
impl<T> Read<Exclusive, BecauseExclusive> for TestRunner
where
T: ?Sized,
impl<T> ToOwned for TestRunner
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T> ToString for TestRunner
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for TestRunner
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for TestRunner
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for TestRunner
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
impl<V, T> VZip<V> for TestRunner
where
V: MultiLane<T>,
fn vzip(self) -> V