Struct credibility::TestBlock[][src]

pub struct TestBlock<'a, St> where
    St: 'a + TestReporter + Sized
{ /* fields omitted */ }

A RAII test result accumulator. The TestBlock defines a unit of test functionality, within which assertions using the macro aver! can fail without aborting the test.

Lifetime & Usage

As soon as a TestBlock variable gets dropped, it kicks off its status tracker's tally method, which (by default) asserts that no failures occurred.

Using results in tests

Since error results are the other "big" cause of early test aborts, test blocks optionally allow code blocks that use them to return results early with ? or try!. To do so ergonomically, use the test_block! macro.

Methods

impl<'a, St> TestBlock<'a, St> where
    St: TestReporter + Sized
[src]

Creates a new TestBlock with a tracker.

Evaluate an aver expression as an assert, catching any panics. Calls the test reporter's averred method with the result of capturing any unwinds.

Called at the end of a block of code that returns a Result.

Trait Implementations

impl<'a, St> Drop for TestBlock<'a, St> where
    St: TestReporter + Sized
[src]

When dropped, TestBlocks call their test reporter's tally method.

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<'a, St> Send for TestBlock<'a, St> where
    St: Send

impl<'a, St> Sync for TestBlock<'a, St> where
    St: Sync