Struct tendermint_testgen::tester::Tester

source ·
pub struct Tester { /* private fields */ }
Expand description

Tester allows you to easily run some test functions over a set of test files. You create a Tester instance with the reference to some specific directory, containing your test files. After a creation, you can add several types of tests there:

  • add_test() adds a simple test function, which can run on some test, deserilizable from a file.
  • add_test_with_env() allows your test function to receive several test environments, so that it can easily perform some operations on files when necessary
  • add_test_batch() adds a batch of test: a function that accepts a ceserializable batch description, and produces a set of test from it

After you have added all your test functions, you run Tester either on individual files using run_for_file(), or for whole directories, using run_foreach_in_dir(); the directories will be traversed recursively top-down.

The last step involves calling the finalize() function, which will produce the test report and panic in case there was at least one failing test. When there are files in the directories you run Tester on, that could not be read/parsed, it is also considered an error, and leads to panic.

Implementations§

source§

impl Tester

source

pub fn new(name: &str, root_dir: &str) -> Tester

source

pub fn env(&self) -> Option<TestEnv>

source

pub fn output_env(&self) -> Option<TestEnv>

source

pub fn add_test<T, F>(&mut self, name: &str, test: F)
where T: 'static + DeserializeOwned + UnwindSafe, F: Fn(T) + UnwindSafe + RefUnwindSafe + 'static,

source

pub fn add_test_with_env<T, F>(&mut self, name: &str, test: F)
where T: 'static + DeserializeOwned + UnwindSafe, F: Fn(T, &TestEnv, &TestEnv, &TestEnv) + UnwindSafe + RefUnwindSafe + 'static,

source

pub fn add_test_batch<T, F>(&mut self, batch: F)
where T: 'static + DeserializeOwned, F: Fn(T) -> Vec<(String, String)> + 'static,

source

pub fn successful_tests(&self, test: &str) -> Vec<String>

source

pub fn failed_tests(&self, test: &str) -> Vec<(String, String, String)>

source

pub fn unreadable_tests(&self) -> Vec<String>

source

pub fn unparseable_tests(&self) -> Vec<String>

source

pub fn run_for_file(&mut self, path: &str)

source

pub fn run_foreach_in_dir(&mut self, dir: &str)

source

pub fn finalize(&mut self)

Auto Trait Implementations§

§

impl Freeze for Tester

§

impl !RefUnwindSafe for Tester

§

impl !Send for Tester

§

impl !Sync for Tester

§

impl Unpin for Tester

§

impl !UnwindSafe for Tester

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> 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> Same for T

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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.